...

View Full Version : Select Onchange Help



byrondallas
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 --
</select>

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

Thank you,
Byron

WolfShade
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">
...
</select>
<input type="text" name="color" value="">
Where formname is the name of the form that these are nested within.

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum