Please, please help with creating a List Menu

Discussion in 'Web Design and Development' started by macaddict23, Mar 13, 2008.

  1. macaddict23 macrumors 6502

    macaddict23

    Joined:
    Jun 20, 2006
    Location:
    MacVille, USA
    #1
    Code:
    <form id="form2" name="form2" method="post" action="">
      <select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu('parent',this,0)">
    <option>Find a Dealer</option>
    <option value="http://www.somelink.com">Dealer 1</option>
    <option value="http://www.somelink.com">Dealer 2</option>
    <option value="http://www.somelink.com">Dealer 3</option>
    <option value="http://www.somelink.com">Dealer 4/option>
    </select>
    </form>
    
    1) My client clicks on Dealer 1, and he's taken to another site.
    2) He hits the back button, and selects "Find a Dealer" from the list and he's taken to a "Page Not Found".

    Sure, it's a "learned behavior" not to click on "Find a Dealer", but the fact is he did, and he was confused. My question is, I didn't specify a value for "Find a Dealer", so I don't understand why he's taken to a page that doesn't exist. I've tried putting a value of <option value=""> and <option value="#"> but I'm taken to the top of the current page, which I don't want because this menu is way at the bottom of the page. Sure, I can probably add anchors, but I'm trying to avoid that. It seems like it's a quick-fix.

    Any clues? Thanks in advance!
     
  2. notnek macrumors 6502

    notnek

    Joined:
    Oct 25, 2007
    #2
    I had a form with a similar subject. Mine was Select A School, and the rest of the options were the names of school's. I found it best to use PHP to decide where to send the user.

    If they select find a dealer, you could echo something like "You must select a dealer" then you could repeat the form or provide a link back.

    Just add a name attribute to each option, then create a page with this code, and have the form send to the new page. Make sure to name the select "dealer" or whatever you have post in the PHP.
     
  3. EvanLugh macrumors 68000

    EvanLugh

    Joined:
    Aug 29, 2007
    Location:
    Developer land
    #3
    Not to do with your problems but;
     
  4. macaddict23 thread starter macrumors 6502

    macaddict23

    Joined:
    Jun 20, 2006
    Location:
    MacVille, USA
    #4
    Good catch Evanlugh. I actually just made a mistake when I copied my source code. I'm still having the same issue. Basically, I don't want "Find a Dealer" to do anything.
     
  5. EvanLugh macrumors 68000

    EvanLugh

    Joined:
    Aug 29, 2007
    Location:
    Developer land
    #5
    If you don't want it to do anything, just leave the value blank, I don't see why it *would* do anything.
     
  6. macaddict23 thread starter macrumors 6502

    macaddict23

    Joined:
    Jun 20, 2006
    Location:
    MacVille, USA
    #6
    Thanks for the help guys. I found the solution.

    <option value="" disabled="disabled">Find a Dealer</option>
     
  7. EvilDog macrumors newbie

    Joined:
    Mar 11, 2008
    #7
    Not to rain on your parade but that won't work in IE 6.0 . . .

    You should wrap the linking action that is part of the function MM_jumpMenu into an if() statement, like this . . .

    function MM_jumpMenu(parent,linkValue,num)
    {
    if (document.getElementById('jumpMenu').selectedIndex > 0)
    {
    //code that activates the jump link goes here
    }
    }

    What this will do is to only activate the jump link if the user has selected an option other than the first one in the list. This will guarantee that it works in all browsers.

    One other thing and that is where you have -

    onchange="MM_jumpMenu('parent',this,0)"

    You may want to change the part where it says this instead -

    onchange="MM_jumpMenu('parent',this.value,0)"

    This will also help to assure cross browser compatibility.

    Hope this helps . . . :cool:
     
  8. Yvan256 macrumors 601

    Yvan256

    Joined:
    Jul 5, 2004
    Location:
    Canada
    #8
    A drop-down menu that activates a script on change is not good:
    - people using the keyboard to browse won't be able to use that type of navigation.
    - people with javascript disabled won't be able to use this either
    - good luck with getting indexed with javascript links.

    sorry if I sound harsh, it's 02:36... gotta go to bed. ;)
     
  9. macaddict23 thread starter macrumors 6502

    macaddict23

    Joined:
    Jun 20, 2006
    Location:
    MacVille, USA
    #9
    I'm not sure what you mean. Can you plug this into my source code above so I have a better idea what you mean? Thanks EvilDog.
     
  10. stndn macrumors member

    Joined:
    Oct 22, 2006
    Location:
    earth
    #10
    Here's an option, although this makes the 'Find a dealer' not selectable:
    HTML:
    <optgroup label="Find a Dealer">
    <option value="http://www.somelink.com">Dealer 1</option>
    <option value="http://www.somelink.com">Dealer 2</option>
    <option value="http://www.somelink.com">Dealer 3</option>
    <option value="http://www.somelink.com">Dealer 4</option>
    </optgroup>
    (I added optgroup for your options)

    Btw, why not make the 'Find a dealer' a label, instead? I think that makes better sense....


    -stndn.
     
  11. macaddict23 thread starter macrumors 6502

    macaddict23

    Joined:
    Jun 20, 2006
    Location:
    MacVille, USA
    #11
    Thanks stndn. Now, how do I make "Find a Dealer" be the default selected item?
     
  12. EvanLugh macrumors 68000

    EvanLugh

    Joined:
    Aug 29, 2007
    Location:
    Developer land
    #12
    Might just be easier to make it obvious to people
    Code:
    <select name="select" size="1" id="select">
        <option>--Find a Dealer--</option>
        <option>Dealer 1</option>
        <option>Dealer 2</option>
        <option>Dealer 3</option>
        <option>Dealer 4</option>
      </select>
    Code:
    <select name="select" size="1" id="select">
        <option>Select a Dealer..</option>
        <option>Dealer 1</option>
        <option>Dealer 2</option>
        <option>Dealer 3</option>
        <option>Dealer 4</option>
      </select>
     
  13. EvilDog macrumors newbie

    Joined:
    Mar 11, 2008
    #13
    Well, there must be some javascripting up in the <head> part of your webpage where you will see a function with the name MM_jumpMenu. Either this or it lives in a separate document with a .js file extension that is referenced to by the webpage. Perhaps you can post a link to the page in question and I should be able to assist you further if I can have a look at how everything is laid out.
     
  14. stndn macrumors member

    Joined:
    Oct 22, 2006
    Location:
    earth
    #14
    Unfortunately, <optgroup>s are not selectable. They are there to group list options only. That's why I suggested having the text label outside the list of options.

    If you want to have selectable options which does not become a valid selection, then you'll have to check the user's selections and verify if it's an acceptable option or not. It's more work than worth it so, unless you have specific reason, you should just move the 'Find a dealer' outside.


    -stndn.
     
  15. notnek macrumors 6502

    notnek

    Joined:
    Oct 25, 2007
    #15
    An easy way to do this is to use PHP if/elseif to check what they selected. If it's Find A Dealer, you can send them back or show them the form again.
     

Share This Page