Selecting list item to auto-populate text fields

Discussion in 'HTML' started by Dave, Jan 25, 2005.

  1. Dave

    Dave Guest

    Hi folks,

    I'm in the middle of adding some validation functionality to an inventory
    tracking form.

    What I would like to do is have one dropdown menu/Listbox(Part Number) and
    another text field (Product Description).

    When the user selects an item from the drop down (IE 12S0FB) it will
    autopopulate the text field with a description of the product. At the
    moment I will hard code the values in. Can anyone help me out here?

    Thanks,
    Dave
     
    Dave, Jan 25, 2005
    #1
    1. Advertisements

  2. Dave wrote:

    > Hi folks,
    >
    > I'm in the middle of adding some validation functionality to an inventory
    > tracking form.
    >
    > What I would like to do is have one dropdown menu/Listbox(Part Number) and
    > another text field (Product Description).
    >
    > When the user selects an item from the drop down (IE 12S0FB) it will
    > autopopulate the text field with a description of the product. At the
    > moment I will hard code the values in. Can anyone help me out here?
    >
    > Thanks,
    > Dave


    You can do this using JavaScript. For example:

    <html>
    <head>
    <script type="text/javascript">
    function addText(myform){
    // get the ID of the text box
    // use document.myform.options[document.myform.myitem.selectedIndex].value
    // to resolve text to insert
    }
    </script>
    </head>


    <body>
    <form name="myform">
    <select name="myitem" onChange="javascript:addText()">
    <option value="item1">Item #1</option>
    <option value="item2">Item #2</option>
    </select>
    </form>
    </body>
    </html>

    Don't try it as it's not tested. It's the idea that counts.

    Roy

    PS - Please don't make corrections, guys. It's just a rough example...

    --
    Roy Schestowitz
    http://schestowitz.com
     
    Roy Schestowitz, Jan 25, 2005
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Criswell
    Replies:
    1
    Views:
    1,568
    John Criswell
    Jul 24, 2003
  2. =?Utf-8?B?UmV6YSBTb2xvdWtp?=

    Not able to populate and select an item in a list dynamically? Hel

    =?Utf-8?B?UmV6YSBTb2xvdWtp?=, Aug 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    444
    Scott Allen
    Aug 25, 2004
  3. C. David Rossen

    Auto Populate Text Box

    C. David Rossen, Sep 24, 2003, in forum: Javascript
    Replies:
    2
    Views:
    262
    C. David Rossen
    Sep 24, 2003
  4. GeekBoy

    Auto-selecting text for user

    GeekBoy, Aug 4, 2004, in forum: Javascript
    Replies:
    1
    Views:
    146
    GeekBoy
    Aug 5, 2004
  5. jzhang29
    Replies:
    1
    Views:
    223
  6. TPK
    Replies:
    1
    Views:
    233
  7. Paul J. Lucas

    Auto-selecting all text in a field

    Paul J. Lucas, Nov 28, 2006, in forum: Javascript
    Replies:
    4
    Views:
    212
    Randy Webb
    Nov 28, 2006
  8. eureka

    Auto populate the Dropdown List

    eureka, Jan 11, 2007, in forum: Javascript
    Replies:
    11
    Views:
    627
    eureka
    Jan 11, 2007
Loading...