View Full Version : Select Onchange Help

07-24-2012, 04:20 AM
This is what I've been using in the past to drop the selected value into a text field, but it doesn't validate. What's the correct way to write this?

<select onchange=form.name.value=this.value;>
<option value="">Choose Color Name</option>
<option value="aliceblue">aliceblue</option>
-- more option values here --

<input type="text" name="name" value="">

Thank you,

07-24-2012, 01:41 PM
Well, for one thing you shouldn't give reserved words (like "name") as the name or id of any object.

Try this:

<select name="selector" onchange="document.formname.color.value = this.value">
<input type="text" name="color" value="">
Where formname is the name of the form that these are nested within.

07-24-2012, 02:36 PM
Works great! Thank you!