I am looking for a script for select all to highlights text in text box, Just like the one in every code page in DD code pages, it is much better if it is auto saved to clipboard, ( acting like Cntrl +A, Cntrl +C )
I am looking for a script for select all to highlights text in text box, Just like the one in every code page in DD code pages, it is much better if it is auto saved to clipboard, ( acting like Cntrl +A, Cntrl +C )
Something like this:
http://www.dynamicdrive.com/dynamici...selectform.htm
(Note: the "Copy to Clipboard" function only works in IE [as far as I am aware of].)
Hope this helps.
The method, actually methods - focus() and select(), for selecting text in a form element like a textarea or text input is rather simple. In most basic terms it is:
where element represents the form element. Form elements can be 'gotten' in a variety of ways and the best way usually depends upon the markup and other things like - the rest of the script.Code:element.focus(); element.select();
Having the text data that you select transferred to the clipboard is a bit more complicated. There is an IE only method and I think there is a way that works in some other browsers or at least a way to make a sort of virtual clipboard.
Accessing the user's clipboard is impolite as, it potentially and in most cases will wipe out any text or image data already on the user's clipboard.
How this is done in IE was gone into in detail here:
http://codingforums.com/showthread.php?t=65106
For other browsers, there is a link to info on that in that thread:
http://www.ms-inc.net/ViewThread.aspx?ThreadID=169
I'm not sure (as already mentioned) if it includes the ability to access the clipboard.
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Thanks, SORRY, I think I was looking on the wrong place in the the Website, That was just what I was looking for![]()
How to make it a button not a text ( the clickable text),
Simply change this:
to this:Code:<a class="highlighttext" href="javascript:HighlightAll('test.select1')">Select All</a>
Hope this helps.Code:<a class="highlighttext" href="javascript:HighlightAll('test.select1')"><img src="image.gif"></a>
actually I am looking for something like
not a gifCode:<BUTTON type="button" OnClick="href="javascript:HighlightAll ('test2.select1'" style="width:70px;height:20px;z-index:2">
also i tried your code it is giving me error
TKS
Last edited by mailtosaleh; 02-28-2007 at 06:51 AM.
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript"> /* Select 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+ //0=no, 1=yes var copytoclip=1 function HighlightAll(theField) { var tempval=eval("document."+theField); tempval.focus(); tempval.select(); if (document.all&©toclip==1&&tempval.createTextRange){ therange=tempval.createTextRange() if(therange.execCommand) therange.execCommand("Copy") else return; window.status="Contents highlighted and copied to clipboard!" setTimeout("window.status=''",1800) } } </script> </head> <body> <form action="#" name="test2"> <input type="button" onclick="HighlightAll ('test2.select1')" style="width:70px;height:20px;z-index:2;" value="Select All"><br> <textarea name="select1" cols="50" rows="5" wrap="virtual">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce luctus turpis. Proin a lacus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed non purus in tellus semper porta. Praesent vel quam nec orci mollis dignissim. Nulla ultrices, tellus quis semper pretium, eros augue eleifend risus, at dictum massa urna blandit metus. Nullam libero metus, scelerisque in, sollicitudin in, tristique nec, tortor. Sed eu felis. Integer rutrum mauris id nisl. Praesent cursus. Vivamus faucibus.</textarea> </form> </body> </html>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Thats great, It looks much better, You are great
Bookmarks