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 07-13-2011, 10:55 PM   PM User | #1
jenniferrs
New to the CF scene

 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jenniferrs is an unknown quantity at this point
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 10:59 PM..
jenniferrs is offline   Reply With Quote
Reply

Bookmarks

Tags
form, form element, javascript, select all, textarea

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 09:40 AM.


Advertisement
Log in to turn off these ads.