Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Drop down list in html or php so that options send to different pages

Options
  • 09-02-2010 6:17pm
    #1
    Registered Users Posts: 67 ✭✭


    I was wondering how to make a drop down list so that when you click a option it will send you to a certain page

    In other words: if i had a drop down list with the options foot,car,bike,van,other
    How could i make it so that when someone chooses foot and clicks a select button it will send them to a page about walking to other places

    When someone chooses car it will send them to a car page...ect


    I know how to make the drop down list and and the select button to send to a page, but just dont know how to make it go to different pages depending on the option they choose

    HTML or PHP will do


Comments

  • Registered Users Posts: 489 ✭✭Pablod


    You can use a basic HTML form with some javascript
    Set up the pages you want your users to be forward to, then test out the Form below... does the job nicely ;)
    <form id="LoginForm" name="AutoListBox">
    <p><select name="ListBoxURL" size="1" language="javascript" onchange="gotoLink(this.form);">
    <option "selected"> -- Select your vehicle -- </option>
    <option value="Car.html">Car</option>
    <option value="Bike.html">Bike</option>
    <option value="Van.html">Van</option>
    </select></p>
    <script language="javascript">
    <!--
    function gotoLink(form) {
    var OptionIndex=form.ListBoxURL.selectedIndex;
    parent.location = form.ListBoxURL.options[OptionIndex].value;}
    //-->
    </script>
       </form>
    


  • Registered Users Posts: 67 ✭✭Fergaloc


    Pablod wrote: »
    You can use a basic HTML form with some javascript
    Set up the pages you want your users to be forward to, then test out the Form below... does the job nicely ;)
    <form id="LoginForm" name="AutoListBox">
    <p><select name="ListBoxURL" size="1" language="javascript" onchange="gotoLink(this.form);">
    <option "selected"> -- Select your vehicle -- </option>
    <option value="Car.html">Car</option>
    <option value="Bike.html">Bike</option>
    <option value="Van.html">Van</option>
    </select></p>
    <script language="javascript">
    <!--
    function gotoLink(form) {
    var OptionIndex=form.ListBoxURL.selectedIndex;
    parent.location = form.ListBoxURL.options[OptionIndex].value;}
    //-->
    </script>
       </form>
    
    Thanks it works


  • Registered Users Posts: 489 ✭✭Pablod


    Fergaloc wrote: »
    Thanks it works
    no problem :D


Advertisement