PDA

View Full Version : Question about focus() and inputText field



Tohaki
10-29-2008, 01:19 PM
I'm using JavaScript to put focus on an <t:inputText> field, which is working. The field in question already contains text though, but the cursor is set at the beginning of the field and not at the end of the input. Does anyone know how I can fix this?

rdutton
10-29-2008, 02:25 PM
A quick search on google revealed this suggestion:

"In some browsers, including IE and FF, the trick is to set the value of the
element after setting the cursor. The cursor will then be moved with it as
the new value is written and end up at the end...

tt.focus(); tt.value = tt.value;"

Found at : http://bytes.com/forum/thread157703.html

Tohaki
10-29-2008, 02:40 PM
Thanks for the tip. :)