Forms II

If I want to create a drop down menu that takes a person to a web site based on their selection, I have to use a little bit of Javascript and the html we learned ion the forms section.

Create a page:

<html>
<head><title>Drop down example</title></head>
<body>

Nothing is here yet!

</body>

</html>

 

 

We will add two things to the page. The first will be some Javascript within the <head> tag.

 

<html>
<head><title>Drop down example</title>

<SCRIPT language="javascript">
<!--
function goTo Link(form)
{
location.href = form.options[form.selected.Index].value;
}
//-->
</script>
</head>

<body>

Nothing is here yet!

</body>

</html>

 

 

 

Now we will add the drop down menu using the form stuff we learned recently>

 

<html>
<head><title>Drop down example</title>

<SCRIPT language="javascript">
<!--
function goToLink(form)
{
location.href = form.options[form.selectedIndex].value;
}
//-->
</script>
</head>

<body>

<form name="gomenu">
<select name="choice">
<option value="http://www.yahoo.com">Yahoo.com
<option value="http://www.rjmudd.com">rjmudd.com
<option value="http://www.dslreports.com">DSL Reports
</select>
<input type="button" value="Let's Go!" onclick="goToLink(this.form.choice)">
</form>

</body>
</html>

Click here to see this work.