listbox selection to autopopulate fields?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    #1

    listbox selection to autopopulate fields?

    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


  • Stephen Chalmers

    #2
    Re: listbox selection to autopopulate fields?


    Dave <overkil6@cogec o.ca> wrote in message
    news:GgrJd.74$i D1.54@read1.cgo cable.net...[color=blue]
    > 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
    >[/color]

    Let's say you've created an array of description strings named descs, your
    form is called form1 and it contains a textarea named descText.

    <select onchange="docum ent.form1.descT ext.value=descs[this.selectedIn dex]">

    --
    S.C.


    Comment

    • RobB

      #3
      Re: listbox selection to autopopulate fields?

      Dave wrote:[color=blue]
      > Hi folks,
      >
      > I'm in the middle of adding some validation functionality to an[/color]
      inventory[color=blue]
      > tracking form.
      >
      > What I would like to do is have one dropdown menu/Listbox(Part[/color]
      Number) and[color=blue]
      > 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[/color]
      the[color=blue]
      > moment I will hard code the values in. Can anyone help me out here?
      >
      > Thanks,
      > Dave[/color]

      Use an object (not an array) to map part numbers to descriptions:

      var p_desc = {
      'IE 12S0FB' : 'Giant Veeblefetzer' ,
      'IE 76S0GB' : 'Tiny Veeblefetzer' ,
      .........
      'IE 22340x' : 'Blue Klarn'
      }

      Then...

      <select...oncha nge="product_de scription.value =(p_desc[this.options[this.selectedIn dex].value]||'')">
      <option value="">choose </option>
      <option value="IE 12S0FB">IE 12S0FB</option>
      .........
      </select>
      <textarea name="product_d escription"></textarea>

      Comment

      Working...