Click to See Complete Forum and Search --> : setting cursor position in text field


jessevitrone
05-28-2003, 10:35 AM
Is there a way to set the cursor position in a text field?

Example: My text field has text in it. I have a spot that I'm setting the focus to that field, and I'd like to set the cursor to be at the end of the text.

Is that possible?

Thanks in advance,
Jesse

khalidali63
05-28-2003, 11:08 AM
you can use
document.formName.fieldName.select()

I guess that will bring you closer to what you want...

crs
05-29-2003, 07:52 AM
This one I know... :)

If would you like to put cursor on the end of field, the this is your sollution:

function setcursor (myObject)
{
myObject.focus();
myObject.value += '';
}

And myObject is formfield object for example:
document.myformName.myinputfieldName

Regards

crs
05-30-2003, 01:52 AM
Actually that works in IE, Mozilla, and Opera and it sets the cursor at the end of text field.

Regards
Bert