[Javascript] Textbox Highlighting

Alan Easton alan.easton at unn.ac.uk
Tue Dec 9 11:19:31 CST 2003


This should do the trick....

<body onload="highlight(0)">
<script>
<!--
function highlight(x){
document.forms[x].elements[0].focus()
document.forms[x].elements[0].select()
}
//-->
</script>
<form>
<TEXTAREA rows=2 cols=20 ID="Textarea1" NAME="Textarea1">Hello all, can we
be highlighted</TEXTAREA>
</form>

Alan...


-----Original Message-----
From: Dave Stoltz [mailto:dstoltz at shh.org]
Sent: 09 December 2003 17:08
To: '[JavaScript List]'
Subject: [Javascript] Textbox Highlighting


How can I set focus to a form textbox, and highlight the text in the box (so
the user doesn't have to highlight with the mouse)???

Thanks!



More information about the Javascript mailing list