Results 1 to 2 of 2

Thread: Dynamically increase width of <input type="text"> as the user types

  1. #1
    Join Date
    Jan 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dynamically increase width of <input type="text"> as the user types

    Is there a way to dynamically increase the width of an input type textbox if the user types in more text than what can be fitted in it?

    Thanks!

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script type="text/javascript">
    /*<![CDATA[*/
    function Expand(obj){
     if (!obj.savesize) obj.savesize=obj.size;
     obj.size=Math.max(obj.savesize,obj.value.length);
    
    }
    /*]]>*/
    </script>
    </head>
    
    <body>
    <form>
    <input name="fred" size="5" onkeyup="Expand(this);" />
    </form>
    
    </form>
    
    </body>
    
    </html>

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
  •