Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2011
    Location
    USA
    Posts
    39
    Thanks
    0
    Thanked 1 Time in 1 Post

    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

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    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".

  • #3
    New Coder
    Join Date
    Jul 2011
    Location
    USA
    Posts
    39
    Thanks
    0
    Thanked 1 Time in 1 Post
    Works great! Thank you!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •