View Full Version : Populating a textbox based on selection in dropdown - NOT DB

06-11-2004, 07:42 PM
Hello, I have been searching through the forums trying to find an answer to this question.

I have a form where there is a dropdown box with a list of vendors. What I want to happen, is that if you select vendor "One", their email address will show up in a textbox. I do not want to use a database to manage this connection. Is there a way I can hard code or use xml to make the correlation between vendor name and email address?

What would the code be to bring over that information into a textbox?

Thank you so much for your help! :confused:

Willy Duitt
06-11-2004, 08:16 PM
Short and to the point:

<select onchange="this.form.email.value=this.value">
<option value="">Vendor</option>
<option value="me@test.com">One</option>
<input type="text" name="email">

06-14-2004, 12:43 PM
This is the cross-browser way of getting the value of the selected option.

<select onchange="this.form.email.value=this.options[this.selectedIndex].value">