Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!

  • #2
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    946
    Thanks
    0
    Thanked 129 Times in 128 Posts
    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>

  • #3
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    946
    Thanks
    0
    Thanked 129 Times in 128 Posts
    And you have another problem:
    innerText is IE-only!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •