Slobrob
08-05-2011, 11:25 PM
Hi guys,
I'm pretty much a newbie when it comes to javascript and i'm still getting to grips with it all but i am in some need of some help.
I'm doing a relatively simple project for a friend of mine and what he is wanting is a simple web page with several buttons that have different information on them.
As you click each button it will automatically copy and then paste into a text area with each bit of information on a new line. I think I have grasped the copy and paste but I am a bit unsure as to how I copy each button and automatically paste into the text area.
once the relevant information is pasted into the textbox - he then wants a button to copy all of that information which can be pasted into a different system.
Here is my code that I have at the moment
<script type="text/javascript">
function copy()
{
Copytext = document.getElementById("button").value;
Copytext.execCommand("Copy");
}
function paste()
{
document.form.textarea.focus();
PasteText = document.form.textarea.createTextRange();
PasteText.execCommand("Paste");
}
</script>
<body>
<form name="form">
<input type="button" onClick="copy()" value="Option 1" />
</br>
<input type="button" onClick="copy()" value="Option 2" />
</br>
<input type="button" onClick="copy()" value="Option 3" />
</br>
<input type="button" onClick="copy()" value="Option 4" />
</br>
<input type="button" onClick="copy()" value="Option 5" />
</br>
<input type="button" onClick="copy()" value="Option 6" />
<p></p>
<textarea id="textarea" cols="60" rows="5"></textarea>
<br />
<input type="button" onClick="copy()" value="Copy text to clipboard" />
</form>
Any help would be appreciated
I'm pretty much a newbie when it comes to javascript and i'm still getting to grips with it all but i am in some need of some help.
I'm doing a relatively simple project for a friend of mine and what he is wanting is a simple web page with several buttons that have different information on them.
As you click each button it will automatically copy and then paste into a text area with each bit of information on a new line. I think I have grasped the copy and paste but I am a bit unsure as to how I copy each button and automatically paste into the text area.
once the relevant information is pasted into the textbox - he then wants a button to copy all of that information which can be pasted into a different system.
Here is my code that I have at the moment
<script type="text/javascript">
function copy()
{
Copytext = document.getElementById("button").value;
Copytext.execCommand("Copy");
}
function paste()
{
document.form.textarea.focus();
PasteText = document.form.textarea.createTextRange();
PasteText.execCommand("Paste");
}
</script>
<body>
<form name="form">
<input type="button" onClick="copy()" value="Option 1" />
</br>
<input type="button" onClick="copy()" value="Option 2" />
</br>
<input type="button" onClick="copy()" value="Option 3" />
</br>
<input type="button" onClick="copy()" value="Option 4" />
</br>
<input type="button" onClick="copy()" value="Option 5" />
</br>
<input type="button" onClick="copy()" value="Option 6" />
<p></p>
<textarea id="textarea" cols="60" rows="5"></textarea>
<br />
<input type="button" onClick="copy()" value="Copy text to clipboard" />
</form>
Any help would be appreciated