How to create drop down menus
Okay, there are 2 kinds of these menus. Firstly I'll start by saying as these are forms using JavaScript, they may not display in all browsers (such as Mozilla's Firefox)...so if you can't see the button menu, it's probably because the JavaScript is hiding it from your incompatable browser. But for those of you using I.E, here's the first example: ...and the second where once you make your selection, you go straight there e.g So how was this done? The code for the menu with an action button is as follows:
And the code for the menu with on selection action is:
Probably the most important thing to take note of is in the Form and Select tags at the start of the script. The Name attributes. In all honesty these can be whatever you like, but if you have more than one menu on a page, they must have different names. Things in bold are items that can be changed. The Option Value's URL or File name is just like in a hyperlink, e.g Sam.html would be entered into the quotation marks. The first Option Value is 'none' and says 'Selected'. This means to choose it, it will go nowhere, it's the default of the menu. Where it says 'Selection 1', 'Selection 2' etc, these are the options displayed to the viewer when they look at the menu. Make them a reasonable description of the page they are linked to. In the first form inside the Script tag where it says form1 and select1, these must match the Form Name and Select Name. It is similar in the second form, in the Select tag, the Select Name must be the same throughout the tag, see where I have highlighted the places in the onchange attribute bold. |
Tutorials © Samantha Coaker