Link to home
Start Free TrialLog in
Avatar of cx3473359
cx3473359

asked on

Form field population from clipboard using a JavaScript

I have a single page which contains multiple forms. I would like the ability to populate certain fields in the different forms with data from the clipboard. Something like; <onclick="document.form1.field.value = document.form2.field.value  = document.form3.field.value = clipboard data">. Onclick causes the clipboard value, which will be a 10 digit number, to be pasted into all of the fields specified.
ASKER CERTIFIED SOLUTION
Avatar of Alopederii
Alopederii

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cx3473359
cx3473359

ASKER

Thanks for the help. I actually modified this a little.

<INPUT TYPE="button" value="Paste Data" onClick="document.form1.field.value = document.form2.field.value =  document.form3.field.value = document.form4.field.value = document.form5.field.value = document.form6.field.value = document.mainform.desired_value.value"
The content area looses focus when you click the button and the paste action applies to the button and is lost. Work around is:

<DIV ID="oContent" contentEditable="true">
This is my area of testing text. You can edit this text.  The paste button won't work though!
</DIV>
<Br>
<input type=button name=cut value="Cut" onClick="oContent.document.execCommand('cut');">
<input type=button name=paste value="Paste" onClick="oContent.focus(); oContent.document.execCommand('paste');">

</BODY>
</HTML>
Oops wrong box, sorry ;)