How to set the cursor to the end of a input box?

  • Follow


My function is going to set some predefined value to a input text box,
and it will focus to the inputbox and set it to the end of the value.

As the title, how to set the cursor to the end of value?

Thanks a lot!

0
Reply cylix2000 (67) 7/9/2007 7:03:13 AM

On Jul 9, 1:03 am, Cylix <cylix2...@gmail.com> wrote:
> how to set the cursor to the end of value?

var i = inputElement // <<<

 var len=i.value.length;
 if(i.setSelectionRange)
  i.setSelectionRange(len,len)
 else if(i.createTextRange){
  var r=i.createTextRange();
  r.moveStart("character",len)
  r.select()
 }
 i.focus()

0
Reply scripts 7/9/2007 10:45:58 AM


1 Replies
313 Views

(page loaded in 0.044 seconds)

Similiar Articles:













7/23/2012 3:07:09 PM


Reply: