Forum Moderators: open

Message Too Old, No Replies

How do I make drop-down boxes at the top of my page?

how to make drop-down boxes at the top of my main page?

         

amythepoet

11:10 pm on Dec 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

I'm doing some redesign today on my homepage. I want to add drop-down menus to the bar at the top of page, which lists the following:

wedding poems,
anniversary poems,
valentine's poems, etc.

I want to have something that says:

Occasions and under occasions, i want the box to drop down and then I will list weddings, anniversaries, etc.

Can you help?

Thanks a lot
-a-

tedster

1:17 am on Dec 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you do a Google search for "dropdown" menu, you will get many options, some of them quite complex. The trend in recent times is to use DHTML (css plus javascript) to reveal new divs when people mouseover a main menu.

But this sounds like you're looking for the most basic kind of select box - the kind that is part of a form - and then change the page depending on what the user chooses.

This script goes in the <head> of your HTML document. It defines a function called "changepage" which your form will call, from down in the body ofn the HTML page. The page will change when someone chooses a new selection from the list.

<script type="text/javascript">
<!--
function changepage(dropdown)
{
selecteditem = dropdown.newurl.selectedIndex;
newurl = dropdown.newurl.options[ selecteditem ].value;
if (newurl.length!= 0) {
location.href = newurl;
}
}
//-->
</script>

And then this form goes in the body of your HTML:

<form action="irrelevant">

<select name="newurl" onchange="changepage(this.form)">
<option value="" selected="selected">-- Occasions --</option>
<option value="weddings.html">Weddings</option>
<option value="anniversary.html">Anniversary</option>
<option value="valentines.html">Valentines</option>
</select>

</form>

amythepoet

1:32 am on Dec 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, sounds great.

-a-