[thelist] js cursor position in a form

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Wed Jan 4 17:19:51 CST 2006


Hi Brian,

   Here's an IE-only approach (there's a Mozilla way as well, which I can provide if you need it):

var inputText = myTextInput.createTextRange();
//  move to the fourth character
inputText.moveStart("character", 4);
//  this will select any text after it so a keypress will 
//   delete the old text and start adding new text
inputText.select(); 

HTH,

Peter

 From: Brian Cummiskey Brian at hondaswap.com

Hi all:

I have a problem with a select box and an input box.

Here's how it works. The office_code is ALWAYS the 1st 4 digits of the 
RepId.

eg,

Office: FLD2
RepId: FLD212345

So, in the select dropdown for the office code, i've added an onchange 
event to call this simple function:

function populaterep() {

var theform = document.getElementById("frmdefault");

if (theform.office_code.value!="")
{
theform.repid_number.value = theform.office_code.value;
theform.repid_number.focus();
}
}

which works fine, but it leaves my cursor blinking at the beginning of 
the input field, not after waiting for the repid number to finish.

Is there a way i can set the cursor to the END of a VALUE in the input box?

This is an internal app, IE6/pc only if it's some weird IE tweak, bring 
it on :)

Thanks in advance for some ideas.



More information about the thelist mailing list