FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


dropdown menus howto?





nunosilva
I'm in the middle of developing my website, and I've come to a part where I want to have a dropdown menu, wich for each category, shows the visitor the possible links to visit.

How can that be done? I'm using php but I don't think that it will be done with it... right?
BlackSkad
  • A JavaScript-way, will automaticaly change from page when an option is chosen:
    Place the piece of code between your head-tags
    Code:
    <SCRIPT language=JavaScript>
       <!--
       function goSelect(daform) {
          with(daform) {
             self.window.location=options[selectedIndex].value;       // jump to that option's value
          }
       }
       //-->
       </SCRIPT>


    Your html-select-box will look like this:
    Code:
    <form>
       <select onchange="goSelect(this)" size="1" name="m">

       <option value="#" >--Pages-
       <option value="index.htm" >index
       <option value="boo.htm" >Boo

       </option>

       </select>
    </form>


  • A php-way, the user still has to push the button though:
    This goes in a file go.php
    Code:
    <?php
    $goPage = (isset($_POST['page'])) ? '/path/to/files/' . $_POST['page'] : $_SERVER['HTTP_REFERRER'];

    header ('location: ' . $goPage);
    exit;
    ?>


    Your HTML will now look like this:
    Code:
    <form>
       <select size="1" name="page">

       <option value="" >--Pages-
       <option value="index.htm" >index
       <option value="boo.htm" >Boo
       </option>

       </select>
       <input type="submit" value="Go!" />
    </form>

nunosilva
thanks for the idea. it is helpful for other things that might come up...
but I explained bad with my intentions...
the idea is to have a menu with navigation links... where I pass with the mouse pointer and the menu shows, and then I choose where to go...
BlackSkad
O, that way, now I get it...
You mean something in this way: http://dhtml-menu.com/ (horizontal)
http://dhtml-menu.com/examples/ex2-vertical-dhtml-menu.html (vertical)
http://www.milonic.com/ (horizontal)
nunosilva
hmmm nice sites there! thanks a lot! dhtml-menu site looks very cool! thanks again! cheers
Related topics
Dropdown menu won't work
[OFFICIAL] World Of Warcraft - No new topics about this
[Java] Top-Down Menu bar tweak.
navigation help
Firefox Extensions Misfiring
Free Javascript Menu Builder?
Javascript expandable menus ... + , -
Sitedesign. Uw tips zijn belangrijk.
Any Mac or Linux users want to took at my site?
CSS help needed with list style menubar
Where do you stand on using Javascript in websites?
Mega Dropdown Menus
populate dropdowns on select
What to learn first?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.