Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

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

  • 09-02-2010 06:17PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 Posts: 490 ✭✭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, Registered Users 2 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, Registered Users 2 Posts: 490 ✭✭Pablod


    Fergaloc wrote: »
    Thanks it works
    no problem :D


Advertisement