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-30-2010, 07:56 PM   PM User | #1
xzile609
New to the CF scene

 
Join Date: Aug 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
xzile609 is an unknown quantity at this point
Noob Question - Multiple Scripts?

I would like to use this code for multiple object on a single page.

Code:
<SCRIPT LANGUAGE="JavaScript">

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

</SCRIPT> 




<SPAN ID="copytext" STYLE="height:150;width:162;background-color:pink">
Text of stuff
</SPAN> 
<TEXTAREA ID="holdtext" STYLE="display:none;">
</TEXTAREA>
<BUTTON onClick="ClipBoard();">Copy to Clipboard</BUTTON>
The problem is im not sure how to get more than 1 SPAN ID to work with the script. any help would be great!
xzile609 is offline   Reply With Quote
Old 08-31-2010, 03:00 AM   PM User | #2
Lerura
Regular Coder

 
Lerura's Avatar
 
Join Date: Aug 2005
Location: Denmark
Posts: 869
Thanks: 0
Thanked 112 Times in 111 Posts
Lerura will become famous soon enough
Code:
<SCRIPT LANGUAGE="JavaScript">

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

</SCRIPT> 


<SPAN ID="copytext" STYLE="height:150;width:162;background-color:pink">
Text of stuff
</SPAN> 
<SPAN ID="copytext2" STYLE="height:150;width:162;background-color:pink">
Stuff to text
</SPAN> 
<TEXTAREA ID="holdtext" STYLE="display:none;">
</TEXTAREA>
<BUTTON onClick="ClipBoard(copytext);">Copy to Clipboard</BUTTON>
<BUTTON onClick="ClipBoard(copytext2);">Copy to Clipboard</BUTTON>
Lerura is offline   Reply With Quote
Old 08-31-2010, 03:11 AM   PM User | #3
Lerura
Regular Coder

 
Lerura's Avatar
 
Join Date: Aug 2005
Location: Denmark
Posts: 869
Thanks: 0
Thanked 112 Times in 111 Posts
Lerura will become famous soon enough
And you have another problem:
innerText is IE-only!
Lerura 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 04:49 PM.


Advertisement
Log in to turn off these ads.