Site hosted by Angelfire.com: Build your free website today!


JavaScript code is typed into an HTML document just like tags. Most JavaScript coding falls between the tags . In order to prevent old browsers from displaying the code to your screen. The following is an example to show you how to create a dropdown box on the Internet by using Javascript language.


Now, you would like to create a select dropdown box with a list of web page you want to go to. The following is the code:
Note: Form and List does not need and in the code.Without the form surrounding the drop down list, some browsers will refuse to allow the JavaScript to work properly.

<form name="goto">
<select name="gotobox"
 OnChange="location.href=goto.gotobox.options[selectedIndex].value">
     <option selected>Please Select the page...
     <option value="https://www.angelfire.com/va2/maryjen/index.html">Mary-Jen's Home Page
     <option value="https://www.angelfire.com/va2/maryjen2/index.html">Mary-Jen's Secret Garden
     <option value="http://www.google.com/">Google Search Engine
</select>
</form>

So, what happened is,

OnChange="location.href=jump1.myjumpbox.options[selectedIndex].value"
So, what happened is: OnChange is an event. location.href is the browser's current location. We are telling the browser to look at the form name: goto, then look at the listbox name. Once the option has been clicked, it will copy the value to the browser's current location.

So if we choose Mary-Jen's Home Page the browser gets the web address as:

location.href=https://www.angelfire.com/va2/maryjen/index.html

We are there!! *^_^*

[ Main Page] [ About Marymount University] [Resume Page] [ AI-Robot Project] [ Christmas Greeting Page] [ Chinese Greeting Page] [ Family Pictures] [ vacation ] [ Honey] [ Song Card Page] [ Daily Taiwanese News]

Sign My Guestbook Guestbook by GuestWorld View My Guestbook