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 to the CF scene
    Join Date
    Jun 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Populating a textbox based on selection in dropdown - NOT DB

    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!

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Short and to the point:

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

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    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">


  •  

    Posting Permissions

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