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 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Select and Copy Element for multiple fields

    I am working with a script from Dynamic Drive (found here) that allows you to select and copy a form element.

    I would like to modify the code to allow me to select multiple form elements with one select all button.

    this is the code for the head section:

    Code:
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"> </script>
    <script language="Javascript">
    <!--
    
    /*
    Highlight and Copy form element script- By Dynamicdrive.com
    For full source, Terms of service, and 100s DTHML scripts
    Visit http://www.dynamicdrive.com
    */
    
    //specify whether contents should be auto copied to clipboard (memory)
    //Applies only to IE 4+
    var copytoclip=1
    
    function HighlightAll(theField) {
    var tempval=eval("document."+theField)
    tempval.focus()
    tempval.select()
    if (document.all&&copytoclip==1){
    therange=tempval.createTextRange()
    therange.execCommand("Copy")
    window.status="Contents highlighted and copied to clipboard"
    setTimeout("window.status=''",1800)
    }
    }
    //-->
    </script>
    and this is what I have so far in the body:

    Code:
    <a class="highlighttext" href="javascript:HighlightAll('form1.select1')">Select All</a><br>
        <div class="form">
        <form name="form1">
        	    <textarea name="select1" rows=1 cols=50 >document name</textarea>  
        <textarea name="select2" rows=1 cols=50 >company</textarea>  
        <textarea name="select3" rows=1 cols=50 >language</textarea>
        	    </form>
        </div>
    From the code, I would like to make it so that I can HighlightAll for each of the textareas (there will be lots of them).

    I have tried a lot of different options...I am not very experienced with Javascript, but have used it from time to time. A little more experienced with jQuery, but not enough to convert this.

    Any help is greatly appreciated.
    Last edited by jenniferrs; 07-13-2011 at 11:59 PM.


 

Tags for this Thread

Posting Permissions

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