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&©toclip==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.