Here is some code that I was playing around with when I was experimenting with cursor positioning and text selection.
Code:
<HTML>
<HEAD>
<SCRIPT TYPE='text/javascript'>
function EOT(txt)
{
var range = txt.createTextRange();
range.move("textedit");
range.select();
}
function EOW(txt)
{
var range = txt.createTextRange();
range.move("word", 2);
range.select();
}
</SCRIPT>
</HEAD>
<BODY>
<TEXTAREA COLS=80 ROWS=4 WRAP=soft>Testing plain vanilla textarea block</TEXTAREA>
<BR><BR>
<TEXTAREA COLS=80 ROWS=4 WRAP=soft ONFOCUS="EOT(this);">Testing EOT in a textarea block</TEXTAREA>
<BR><BR>
<INPUT TYPE=text SIZE=50 VALUE="Testing EOT in an input block" ONFOCUS="EOT(this);">
<BR><BR>
<INPUT TYPE=text SIZE=50 VALUE="Testing plain vanilla input block">
<BR><BR>
<INPUT TYPE=text SIZE=50 VALUE="Testing EOW in an input block" ONCLICK="EOW(this);">
<BR><BR>
<INPUT TYPE=text SIZE=50 VALUE="Testing clear on select" ONFOCUS="this.value = '';">
<BR><BR>
<INPUT TYPE=text SIZE=50 VALUE="Testing highlight all on select" ONFOCUS="this.select();">
</BODY>
</HTML>
*Edited to add the code for select all - just in case anyone needs to do this