View Full Version : highlight textarea contents
raoul
12-09-2002, 10:57 PM
I tried to find information on this subject but couldn't find anything about it.
Am I right that it is not possible to dynamically select the contents of a textarea?
Or perhaps with vbscript?
Thanks,
Raoul
glenngv
12-10-2002, 01:19 AM
do you mean this?
<form>
<textarea name="texta">
this is a
textarea
blah
blah
</textarea>
<input type="button" value="Hilite" onclick="this.form.texta.select()">
</form>
whammy
12-10-2002, 06:43 AM
If you're talking about selecting specific text within a textarea, etc. it can only be done in IE using createTextRange() and other proprietary IE functions (in JScript, not really JavaScript, and I would avoid using VBScript unless you are on an intranet where people are required to use Internet Exploder)... therefore I avoid them, personally, since they are not cross-browser compatible.
If on the other hand you just want to select the textarea contents, the code that Glenn posted above should do that perfectly.
:)
raoul
12-10-2002, 08:07 AM
Yes, thanks! I need to select all textarea contents so that works great.
Raoul
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.