SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quick question about drop down menus.

    I have a dropdown menu with this code:

    <p class="l-mid"><label for="imclient" accesskey="12">Instant Messenger Client</label>
    <select name="imclient" id="imclient" tabindex="12">
    <option selected>Choose One</option>
    <option value="aim">AIM</option>
    <option value="msn">MSN</option>
    <option value="yahoo">Yahoo</option>
    <option value="icq">ICQ</option>
    <option value="gtalk">GTalk</option>
    </select>
    </p>

    When a user selects a dropdown option and then submits the form (user profile on my site), it submits the value of that option. But if they dont select an option and submit the form when the default "Choose One" option is selected, it submits "Choose One" as the value. I would like it to not submit anything so that "Choose One' doesn't override their previously selected option. Thanks in advance!

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if they dont select an option and submit the form when the default "Choose One" option is selected, it submits "Choose One" as the value.
    Not in IE6. So, to get IE6 and FF to have the same value, do this:

    <option value="" selected>Choose One</option>

    But even then, "" is still a value. And all names and their values get submitted to the server. So you need to do something like this on the server side:
    Code:
    if(submittedVal != "")
    {
            elementValue = submittedVal;
    }
    Last edited by 7stud; Jan 13, 2007 at 15:24.

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool that worked, thanks a lot!


Bookmarks

Posting Permissions

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