Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-05-2002, 06:11 PM   PM User | #1
cozenage
New to the CF scene

 
Join Date: Jul 2002
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
cozenage is an unknown quantity at this point
Question Expanding this function to accomodate multiple items

I have the following bit of code:
<SCRIPT LANGUAGE="JavaScript">

function ClipBoard()
{
holdtext.innerText = copytext.innerText;
Copied = holdtext.createTextRange();
Copied.execCommand("Copy");
}

</SCRIPT>

I use it to copy items to the clipboard. It works great when I only have one piece of information to deal with (one "holdtext", one "copytext").

I want to expand the capabilities of this function in order to accomodate more than one piece of information. Something that will allow me to pass it an integer ("ClipBoard(1);", or "ClipBoard(100334);") instead of it dealing with just one.

thanks!
cozenage is offline   Reply With Quote
Old 08-05-2002, 06:35 PM   PM User | #2
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
See if this does what you require.

<script>
function Copy(n){
copyme=n
textRange = document.body.createTextRange();
textRange.moveToElementText(copyme);
textRange.execCommand("Copy");
}
</script>

<a href="#null" onclick="Copy(copyit)">Copy To Clipboard</a>

<P><a href="#null" onclick="Copy(copyit2)">Copy To Clipboard2</a>

<P><div id=copyit>This would be the first text range to be copied</div>

<P><div id=copyit2>This is the second range of text to be copied by the same script
</div>
Mr J is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:28 PM.


Advertisement
Log in to turn off these ads.