Click to See Complete Forum and Search --> : automatically copy
Webskater
11-01-2004, 11:48 AM
I would like to be able to have people click on a link and the effect would be that a certain amount of hidden text would be automatically copied. So they click on a name and, for example, the name and address would automatically be copied so they can paste it into another document. Is this possible?
Thanks for any help.
Warren86
11-01-2004, 02:07 PM
<HTML>
<Head>
<Script Language=JavaScript>
var isSecond = false;
var isFirst = true;
function copyToClipboard(ID){
isRange = document.body.createControlRange();
isRange.add(document.all(ID))
if (isSecond)
{if (confirm('This will erase the Clipboard. \n\nDo you want to CONTINUE?')){isRange.execCommand("Copy");alert('The Clipboard was overwritten with your selection.')}}
else if (isFirst){isRange.execCommand("Copy");isFirst = false;
alert('Your selection was copied to the Clipboard.')}
isSecond = true;
}
</Script>
<Body>
<center>
<H3>Copy Selected and Hidden Data to Clipboard</H3>
<Table id='data1' Style='display:none'><TD>John Doe, 456 Any Street, Columbus, OH 44444</TD></Table>
<a href=javascript:copyToClipboard('data1') id='name1'>John Doe</a><br>
<Table id='data2' Style='display:none'><TD>Mary Roe, 123 Main Street, Avalon, PA 22222</TD></Table>
<a href=javascript:copyToClipboard('data2') id='name2'>Mary Roe</a><br>
<Table id='data3' Style='display:none'><TD>Henry Crow, 987 Easy Street, Paradise, CA 55555</TD></Table>
<a href=javascript:copyToClipboard('data3') id='name3'>Henry Crow</a>
</center>
</Body>
</HTML>
Webskater
11-01-2004, 03:44 PM
Thanks very much. I was hoping for an idea how to do it - but the whole code! Brilliant! Thanks again.
Warren86
11-01-2004, 04:04 PM
You're welcome. Thank you for your kind consideration.