...

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



Merlee
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:


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

glenngv
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">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum