dcsimg

Assignment 27: A Possible Answer

This:

<SCRIPT LANGUAGE="javascript">
function LinkUp()
{
var number = document.DropDown.DDlinks.selectedIndex;
location.href = document.DropDown.DDlinks.options[number].value;

}
</SCRIPT>

<FORM NAME="DropDown">
<SELECT NAME="DDlinks">
<OPTION SELECTED VALUE="assignment27.html">On Site Links
<OPTION VALUE="page.html" > Page One
<OPTION VALUE="page2.html"> Page Two
<OPTION VALUE="page3.html"> Page Three
</SELECT>
<INPUT TYPE="BUTTON" VALUE="Click to Go!" onClick="LinkUp()">
</FORM>

<SCRIPT LANGUAGE="javascript">
function LinkUp2()
{
var number2 = document.DropDown2.DDlinks2.selectedIndex;
location.href = document.DropDown2.DDlinks2.options[number2].value;

}
</SCRIPT>

<FORM NAME="DropDown2">
<SELECT NAME="DDlinks2">
<OPTION SELECTED VALUE="assignment27.html">Off Site Links
<OPTION VALUE="http://www.htmlgoodies.com"> HTML Goodies
<OPTION VALUE="http://www.developer.com"> Developer.com
<OPTION VALUE="http://www.earthweb.com"> EarthWeb
</SELECT>
<INPUT TYPE="BUTTON" VALUE="Click to Go!" onClick="LinkUp2()">
</FORM>

 

Gives you this:

     There's a lot of code up in there. The way I did it was to simply copy the original code, change out the local link VALUEs with off-site values, and update all the names and variable names. By "update" I mean I added the number 2 to each one.

     Remember, this is a whole new script and it cannot have the same variables or form item names as the original or you'll get errors galore.

 

Did You Get It?

 

Back to the Index Page