Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    glz
    glz is offline
    New Coder
    Join Date
    Apr 2007
    Posts
    57
    Thanks
    3
    Thanked 0 Times in 0 Posts

    focusing on text input field

    How can I place the text cursor in a certain position among text in a <input type="text" /> form field?


    for example let's say the input field contains this value:
    hello

    I want to place the blinking cursor before the 'h'
    I want to place the linking cursor after the 'o'

    How JS code do I need to do this?
    I tried focus() but this just places the focus on the form field, and does not change cursor position.

    Thanks

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    I am afraid that I do not understand the question. What is it which will cause the cursor to be placed before the 'h' or after the 'o'? User focusing on the field? If so what logic applies?

    Have a look at:-

    http://www.codingforums.com/showthread.php?t=87984
    Last edited by Philip M; 12-24-2007 at 07:49 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •