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 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    69
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Other option in webform dropdown

    I have some code for a dropdown where when the 'Other' option is selected a textbox appears and the user can put in their info.

    What I'm wondering is, how can i set it up so if the Other option isn't selected the dropdown info is sent to my database Name field, and if the Other option is selected it sends the info that's typed in to the Name field in my database and does nothing with the actual 'Other' label in the dropdown?

    here's the code i have so far

    Code:
    <script language="JavaScript" type="text/javascript">
    <!--
    function getOther(sel,fld){
    fld.style.display = (sel.selectedIndex==sel.options.length-1)?"inline":"none";
    }
    //-->
    </script>
    <select name="Name" id="Name" onchange="getOther(this,this.form.oth);">
    <option>Name 1
    <option>Name 2
    <option>Name 3
    <option>Name 4
    <option>Name 5
    <option>Other
    </select>
    <br><input type="text" name="Other" style="display: none;">

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by KatieK View Post
    What I'm wondering is, how can i set it up so if the Other option isn't selected the dropdown info is sent to my database Name field, and if the Other option is selected it sends the info that's typed in to the Name field in my database and does nothing with the actual 'Other' label in the dropdown?
    Surely that's a matter for the receiving script on the server.


  •  

    Posting Permissions

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