By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,944 Members | 1,603 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,944 IT Pros & Developers. It's quick & easy.

listbox selection to autopopulate fields?

P: n/a
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
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Dave <ov******@cogeco.ca> wrote in message
news:Gg*************@read1.cgocable.net...
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


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="document.form1.descText.value=descs[this.selectedIndex]">

--
S.C.
Jul 23 '05 #2

P: n/a
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


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...onchange="product_description.value=(p_d esc[this.options[this.selectedIndex].value]||'')">
<option value="">choose</option>
<option value="IE 12S0FB">IE 12S0FB</option>
.........
</select>
<textarea name="product_description"></textarea>

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.