SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    going to select1.htm directly when it's selected

    The following code doesn't work correcltly, but it will show what I want.
    Code:
    <select name=''>  
    
    <option>▼ select below</option>
    <option><a href='select1.htm'>go to select1</a></option>
    <option><a href='select2.htm'>go to select2</a></option>
    <option><a href='select3.htm'>go to select3</a></option>
    
    </select>
    I like to make it going directly as sonn as it's selected without clicking any submit button.

    Can I do it with your help?

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    I have a series of tutorials on the different ways to do it at http://javascript.about.com/od/dropdownnavigation/ that covers both how to use Javascript to do what you want and how to code it so it still works without Javascript.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice work, Stephen!

  4. #4
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MikeFoster
    Nice work, Stephen!
    Yes, it has good tutorials. But I don't get the solution of my problem yet.

  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Those tutorials give an excellent answer to your question. They even show how to make it work with and without Javascript being enabled. All you have to do is copy his code.

    In regards to the code you posted, note that OPTION elements cannot contain other elements (w3c reference).

    If you have questions about felgall's tutorials then I'm sure he would be glad to answer them. Please provide specific questions. When you say "I don't get the solution of my problem yet" - we have no idea how to help you.

  6. #6
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MikeFoster
    Those tutorials give an excellent answer to your question. They even show how to make it work with and without Javascript being enabled. All you have to do is copy his code.

    In regards to the code you posted, note that OPTION elements cannot contain other elements (w3c reference).

    If you have questions about felgall's tutorials then I'm sure he would be glad to answer them. Please provide specific questions. When you say "I don't get the solution of my problem yet" - we have no idea how to help you.
    The tutorials are really good although I have not found the solution of my original problem, but the Forum is, I am afraid, not good. Although I joined the site as a member. I couldn't post any of my problem.

    I think felgall is really good at Javascript but might be not good at Database...


    I am still finding the way how to get what I want.

  7. #7
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, you are totally confusing me.

    Here, this is practically the same as the tutorial describes but it doesn't work without javascript enabled.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Drop Down Menu</title>
    <script type='text/javascript'>
    window.onload = function()
    {
      document.getElementById('menu1').onchange = ddmOnChange;
    }
    function ddmOnChange()
    {
      var url = this.options[this.selectedIndex].value;
      //alert(url); return;
      document.location = url;
    }
    </script>
    </head>
    <body>
    <form>
    <div>
    <select id='menu1'>
    <option value='pg1.html'>Page 1</option>
    <option value='pg2.html'>Page 2</option>
    <option value='pg3.html'>Page 3</option>
    </select>
    </div>
    </form>
    </body>
    </html>

  8. #8
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you. your code works totally fine.


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
  •