Bluelude1
01-30-2003, 08:38 PM
I found this code for a linked drop down menu
http://developer.irt.org/script/1046.htm
I am trying to tie this menu into my ASP database so that when a user makes their selections it dynamically builds the code for the database query.
Here is a sample of the code design setup of my site http://www.boostdriven.com/productlist.asp?cat=8&car=1&code=1D&year=1999
Cat=8 (Category of Product)
Car=1 (Vechile Make)
Code=1D (Vechile Model)
Year=1999 (Vechile Year)
Basically im trying to make it so that I start with a set Address like
http://www.boostdriven.com/productlist.asp?cat=8
And then the menu adds the Car, Code, and Vechile sections
But want I understand from talking to a couple friends that kinda know javascript is that script above is for a menu with direction set in the code not in a database. What can I do about this ... is there a better code out there that someone knows
Im totally lost an frustrated with this thing .. spent the last 3 days searching google for an answer and would be extremely appreciative if someone could please help me
Thanks
Dane
Bluelude1
01-30-2003, 11:00 PM
Hey dave just to make sure this is the same thing we are talking about i have had a difficult time describing this thing. I went ahead an attached the script , at the bottom of this page, for the drop down menu i am trying to use
Basically I am looking for a Script that can
Take a base link like
http://www.boostdriven.com/productlist.asp?cat=8
and then as the user makes their selection the menu cookies the selections an then adds them to the end of base link and you end up with
http://www.boostdriven.com/productlist.asp?cat=8&car=1&code=1D&year=1999
which just has these codes:
Cat=8 (Category of Product)
Car=1 (Vechile Make)
Code=1D (Vechile Model)
Year=1999 (Vechile Year)
Inserted by the drop down menu selections and then when a person hits the "Submit" button the link that was compiled is accessed. If your having a hard time understanding what i am trying to say please let me know and i will try to explain in more detail .....this is the only place I have found where the memebers are nice enough to try and help you if they can.
Thanks
Dane
code:--------------------------------------------------------------------------------
<html>
<head>
<script language="JavaScript"><!--
var whatForm, whatTo, whatText;
function reshow(number) {
whatFrom = document.forms['formName' + number].elements['selectName' + number];
number++;
whatTo = document.forms['formName' + number].elements['selectName' + number];
for (var i = whatTo.length;i > 0;i--)
whatTo.options[0] = null;
whatText = whatFrom.options[whatFrom.selectedIndex].text;
showLink(number);
whatTo.options[0].selected = true;
if (number == 2)
reshow(2);
return false;
}
function load(number) {
what = document.forms['formName' + number].elements['selectName' + number];
window.location.href = what.options[what.selectedIndex].value;
return false;
}
function showLink(number) {
if (number == 2)
showLink2()
else if (number == 3)
showLink3();
}
function showLink2() {
if (whatText == 'Red') {
opt('red/ball.htm','Red Ball');
opt('red/hat.htm','Red Hat');
}
if (whatText == 'Green') {
opt('green/grass.htm','Green Grass');
opt('green/tree.htm','Green Tree');
}
if (whatText == 'Blue') {
opt('blue/sky.htm','Blue Sky');
opt('blue/car.htm','Blue Car');
}
}
function showLink3(text) {
if (whatText == 'Red Ball') {
opt('red/ball/round.htm','Round Red Ball');
opt('red/ball/flat.htm','Flat Red Ball');
}
if (whatText == 'Red Hat') {
opt('red/hat/top.htm','Red Top Hat');
opt('red/hat/flap.htm','Red Flap Cap');
}
if (whatText == 'Green Grass') {
opt('green/grass/tall.htm','Tall Green Grass');
opt('green/tree/cut.htm','Green Cut Grass');
}
if (whatText == 'Green Tree') {
opt('green/tree/oak.htm','Green Oak Tree');
opt('green/tree/elm.htm','Green Elm Tree');
}
if (whatText == 'Blue Sky') {
opt('blue/sky/cloudy.htm','Cloudy Blue Sky');
opt('blue/sky/clear.htm','Clear Blue Sky');
}
if (whatText == 'Blue Car') {
opt('blue/car/sports.htm','Blue Sports Car');
opt('blue/car/racing.htm','Blue Racing Car');
}
}
function opt(href,text) {
var optionName = new Option(text, href, false, false)
var length = whatTo.length;
whatTo.options[length] = optionName;
}
//--></script>
</head>
<body>
<center>
<form name="formName1" onSubmit="return load(1)">
<select name="selectName1" onChange="reshow(1)">
<option value="red.htm" selected>Red
<option value="green.htm">Green
<option value="blue.htm">Blue
</select>
<input type="submit" value="Go">
</form>
<form name="formName2" onSubmit="return load(2)">
<select name="selectName2" onChange="reshow(2)">
<option value="red/ball.htm" selected>Red Ball
<option value="red/hat.htm">Red Hat
</select>
<input type="submit" value="Go">
</form>
<form name="formName3" onSubmit="return load(3)">
<select name="selectName3">
<option value="red/ball/round.htm" selected>Round Red Ball
<option value="red/hat/flat.htm">Flat Red Hat
</select>
<input type="submit" value="Go">
</form>
</center>
</body>
</html>
Bluelude1
01-31-2003, 07:52 AM
Hey Dave what if I want to be able to allow the user to submit from any point whether they have selected just one category or all 3. on an where am i gonna need to input the codes does the below look correct ?
Code:.............................................................................................
function showLink2() {
if (whatText == 'ACURA') {
opt('Integra.htm','1A');
opt('RSX','2A');
}
Thanks for all your help Dave
Dane
Bluelude1
02-01-2003, 10:59 AM
Hey Dave
Thanks a million looks like the first one you sent will prolly work best for me. Just one last question... is it very hard to get the ASP to build the options in the select boxes ?
Thanks
Dane