View Full Version : I need something similar to Triple Combo Menu
Don Graham
07-24-2003, 08:54 PM
I need a Java Script that is similar to the Triple Combo Menu except all three menus will have constant selections and a Submit button.
The user will select from menu 1 then then menu 2 then select Submit to retrieve an htm page.
Or the user will select from menu 1 then menu 2 then menu 3 then select Submit to retrieve an htm page.
Can anyone point me in a direction of where I can even find a sample to work from? Can the Triple Combo Menu be changed to do this?
Thank you in advance.
Don
fredmv
07-24-2003, 09:00 PM
Hey Don!
I could put together an example right now for you. I'll be done in a few minutes.
<script type = "text/javascript">
function redirect()
{
location.href = document.form.sel1.value + "_" + document.form.sel2.value + "_" + document.form.sel3.value;
return;
}
</script>
Then just make the HTML form with three <select> elements and define a value for each option element, it should work perfectly.
Good luck.
Don Graham
07-25-2003, 04:32 PM
Awesome I will try it right now. Thank you very much.
Don
Don Graham
07-25-2003, 05:26 PM
Fred,
Thank you very much. I think I am close. Here is what I put together using your example. I am certain I am missing something though. Can you please look at my example? NOTE: I have files named one.htm, one001.htm, one0012003.htm and so on... So there is a unique htm file for each combinations of selections.
--------------------------
<HEAD>
<script type = "text/javascript">
function redirect()
{
location.href = document.form.sel1.value + "_" + document.form.sel2.value + "_" + document.form.sel3.value;
return;
}
</script>
</HEAD>
<BODY>
<center>
<form name=menufrm>
<select name=menu1>
<option value="">form</option>
<option value="one">One</option>
<option value="two">Two</option>
<option value="three">Three</option>
</select>
<select name=menu2>
<option value="">Unit</option>
<option value="001">001</option>
<option value="002">002</option>
<option value="003">003</option>
</select>
<select name=menu3>
<option value="">Year</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
</select>
<input name="Submit" type=submit onClick="combineMenus(this.form, this.form.menu1, this.form.menu2, this.form.menu3)" value="Select">
</form>
</center>
<p><center>
</center>
cheesebagpipe
07-25-2003, 05:50 PM
Why 'corrupt' your file naming to adapt to other data? JS can map whatever you need to whatever you need.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="javascript">
var redirectURLs = Object(); //put URLs here, keyed to particular combinations of digits (option choices)
redirectURLs['14'] = 'http://www.google.com'; //first two options
redirectURLs['369'] = 'http://www.codingforums.com'; //last three in all three lists
function redir(oSelect1,oSelect2,oSelect3) {
var sKey = '';
sKey += oSelect1.options[oSelect1.selectedIndex].value;
sKey += oSelect2.options[oSelect2.selectedIndex].value;
sKey += oSelect3.options[oSelect3.selectedIndex].value;
if (redirectURLs[sKey])
self.location = redirectURLs[sKey];
else alert('Please select another combination, you twit.');
}
</script>
</head>
<body>
<form>
<select name="menu1">
<option value="">form</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<select name="menu2">
<option value="">Unit</option>
<option value="4">001</option>
<option value="5">002</option>
<option value="6">003</option>
</select>
<select name="menu3">
<option value="">Year</option>
<option value="7">2003</option>
<option value="8">2002</option>
<option value="9">2001</option>
</select>
<input type="button" value="Go To" onclick="redir(menu1,menu2,menu3)">
</form>
</body>
</html>
Don Graham
07-25-2003, 06:11 PM
The example is totally awesome. It is exactly what I needed. Thank you very much.
Don:thumbsup:
cheesebagpipe
07-25-2003, 06:14 PM
Don....
spiced it up a bit. :D
cbp
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.