View Full Version : list/menu link to web pages
Rookie
09-17-2002, 08:38 AM
I am designing a website in Dreamweaver and I am having trouble with the list/menu form. The purpose of this list/menu form is to send users to internal website urls. I need to create the correct javascript for the following list/menu:
<select size="1" name="myJumpToBox" onChange="dojump(this);">
<option value="value" selected>Choose a topic </option>
<option value="www.jimnicholsrealty.com">Buying </option>
<option value="www.buying.com">Selling </option>
<option value="www.selling.com">Financing </option>
</select>
If anyone has a solution please help.
THE ROOKIE
<html>
<head>
<title>Untitled</title>
<script language="javascript" type="text/javascript">
<!-- ;
function dojump(f) {
f=f1.myJumpToBox
location.href = f.options[f.selectedIndex].value;
}
// -->
</script>
</head>
<body>
<form name="f1">
<select size="1" name="myJumpToBox" onChange="dojump(this)">
<option value="javascript:void(0)" selected>Choose a topic </option>
<option value="http://www.jimnicholsrealty.com">Buying </option>
<option value="http://www.buying.com">Selling </option>
<option value="http://www.selling.com">Financing </option>
</select>
<input type="button" value="Go!" onclick="dojump(this)">
</form>
</body>
</html>
I put a button in for backwards compatability and made void the default selected option so you don't get errors if smeone selects or clicks that option.
note: I made some changes to this unaware of glenngv's optimsed version
glenngv
09-17-2002, 09:45 AM
just an optimized version:
<html>
<head>
<title>Untitled</title>
<script language="javascript" type="text/javascript">
<!-- ;
function dojump(objSelect) {
url = objSelect.options[objSelect.selectedIndex].value;
if (url!="") location.href = url;
}
// -->
</script>
</head>
<body>
<form name="f1">
<select size="1" name="myJumpToBox" onChange="dojump(this)">
<option value="" selected>Choose a topic </option>
<option value="http://www.jimnicholsrealty.com">Buying </option>
<option value="http://www.buying.com">Selling </option>
<option value="http://www.selling.com">Financing </option>
</select>
<input type="button" value="Go!" onclick="dojump()">
</form>
</body>
</html>
Rookie
09-18-2002, 02:57 AM
Thanks for the feedback. I inserted the javascript into my page and the script was up and running efficiently. I appreciate your prompt feedback and expertise.
Kyle
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.