Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-24-2012, 04:20 AM   PM User | #1
byrondallas
New Coder

 
Join Date: Jul 2011
Location: USA
Posts: 39
Thanks: 0
Thanked 1 Time in 1 Post
byrondallas is an unknown quantity at this point
Select Onchange Help

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?

Code:
<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
byrondallas is offline   Reply With Quote
Old 07-24-2012, 01:41 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 941
Thanks: 7
Thanked 95 Times in 95 Posts
WolfShade is an unknown quantity at this point
Well, for one thing you shouldn't give reserved words (like "name") as the name or id of any object.

Try this:
Code:
<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.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 07-24-2012, 02:36 PM   PM User | #3
byrondallas
New Coder

 
Join Date: Jul 2011
Location: USA
Posts: 39
Thanks: 0
Thanked 1 Time in 1 Post
byrondallas is an unknown quantity at this point
Works great! Thank you!
byrondallas is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:18 AM.


Advertisement
Log in to turn off these ads.