Results 1 to 3 of 3

Thread: issue with <input type='textbox'>

  1. #1
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question issue with <input type='textbox'>

    i have a <input type='textbox'> which has some text n when i click anywhere inside it, the cursor has to be move to the end of the string

    one more issue is like:

    the above <input type> with some text inside it is in readonly mode n when i click inside the <input type> it has to change to edit mode with the cursor aligned to extreme right of the string.

    Any one with quick response would be highly appreciated as it is required on urgent basis.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    1) It's:
    Code:
    <input type="text">
    2) Make sure that you don't have any align on your element:
    Code:
    <input type="text" style="text-align:right">
    3) If your not, make your code this:
    Code:
    <input type="text" style="text-align:left">
    Jeremy | jfein.net

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    function setCaretTo(obj, pos){
     if(obj.selectionStart){
      obj.focus();
      obj.setSelectionRange(pos, pos);
     } else if(obj.createTextRange){
      var range = obj.createTextRange();
      range.move('character', pos);
      range.select();
     }
    };
    
    function readWrite(t){
     if(!t.onclick.clicked){
      t.onclick.clicked=true;
      t.removeAttribute('readonly', 0);
      setCaretTo(t, t.value.length);
      t.blur();
      t.focus();
     }
    };
    </script>
    </head>
    <body>
    <input type="text" readonly onclick="readWrite(this);" value="something"><br>
    </body>
    </html>
    Last edited by jscheuer1; 11-12-2008 at 03:39 PM. Reason: minor code improvement
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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