Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

th/td highlight

Status
Not open for further replies.

eriol

Programmer
Jun 25, 2002
4
US
I've been trying to figure out how to make a table header cell or table data cell highlight in order to copy it to a client's clipboard (assuming they use msie 4+).. It's similar to this form element highlight script at dynamic drive:


But instead of just copying a form element, I need it to copy an entire <th></th> or <td></td> area instead.. I've been fiddling around with &quot;document.tablename.tdname.selection&quot;, but I'm not skilled enough with JavaScript to figure it out.. I want clients who view my PHP source code to be able to have a simple means of copying it.. Is this possible? If so, how would I go about it? Any help or pointers would be appreciated..

Here's the code from the URL above:

Code:
<script language=&quot;Javascript&quot;>
<!--
var copytoclip=1
function HighlightAll(theField){
  var tempval=eval(&quot;document.&quot;+theField)
  tempval.focus()
  tempval.select()
  if (document.all&&copytoclip==1){
    therange=tempval.createTextRange()
    therange.execCommand(&quot;Copy&quot;)
    window.status=&quot;Contents highlighted and copied&quot;
    setTimeout(&quot;window.status=''&quot;,1800)
  }
}
//-->
</script>

<form name=&quot;test&quot;>
  <a href=&quot;javascript:HighlightAll('test.select1')&quot;>Select All</a>
  <br>
  <textarea name=&quot;select1&quot; rows=10 cols=35 >
    This is some text. This is some text.
    This is some text. This is some text.
  </textarea>
</form>

TIA

Take care.. peace..
eriol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top