ok... i am setting the focus to a text box by
document.sender.message.focus
... but what if the text box has some text in it already and i want the cursor thing to be placed after the text... how can i do that ???
thanks kris
Printable View
ok... i am setting the focus to a text box by
document.sender.message.focus
... but what if the text box has some text in it already and i want the cursor thing to be placed after the text... how can i do that ???
thanks kris
Here is some code that I was playing around with when I was experimenting with cursor positioning and text selection.
*Edited to add the code for select all - just in case anyone needs to do thisCode:<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>