...

View Full Version : Easy question about drop down menu/drop box



mat420
05-14-2008, 04:16 AM
I need help with a drop box. Not a button that opens sub menus but I need a drop box like this...here the drop box is dropped down
http://irt.austincc.edu/blackboard/images/dropbox_send.gif

the ones where u click the little arrow on the right and more options come down


now i know how to create one of those but, how do u make it so, if drop box 1 says "size 1" and drop box 2 says "color:blue" it goes to one link

but if one drop box says "size 1" and the other says "color:green" it goes to another link? thanks so much guys.

binaryWeapon
05-14-2008, 04:41 AM
The basic idea:


<form name="myform"><select name="obj1"><option>blah</option></select><select name="obj2"><option>blah blah</option></select><input type="button" value="Go" onClick="go(document.myform.obj1.value,document.myform.obj2.value)"></form>

<script>
function go(obj1, obj2)
{
if(obj1=="blah" && obj2=="blah blah") alert("Hello world");
}
</script>

A similar effect is the "Double Drop-Down Menu" effect. In that type, when you select an option in the first select box, the options in the second one change. If your interested in that Google "Double Drop-Down Menu" (http://www.google.com/search?hl=en&q=double+drop-down+menu&btnG=Search).

mat420
05-14-2008, 06:32 AM
thanks so much
i suck at html so it wasnt easy to fix

i had to make it:

<form name="myform"><select name="obj1"><option>blah</option></select><select name="obj2"><option>blah

blah</option></select><input type="button" value="Go"

onClick="go(document.myform.obj1.value,document.myform.obj2.value)"></form>
<script type="text/javascript">

function go(obj1, obj2)
{
if(obj1=="blah" && obj2=="blah blah") alert("Hello world");
}
</script>


to work. i guess the script type is what did it? i suck really bad..

now what can i change alert("hello"); to, to make it visit a link please? thank u so so so so much man.

mat420
05-14-2008, 07:09 AM
got it!!!!! thanks so much man u saved me alot of stress.
aim screenname: mcg if u ever need anything :)
<html>
<body>


<form name="myform"><select name="obj1"><option>blah</option></select><select name="obj2"><option>blah

blah</option></select><input type="button" value="Go"

onClick="go(document.myform.obj1.value,document.myform.obj2.value)"></form>
<script type="text/javascript">

function go(obj1, obj2)
{
if(obj1=="blah" && obj2=="blah blah") document.location.href="http://www.go.com";
}
</script>

binaryWeapon
05-14-2008, 03:02 PM
Glad to help! :thumbsup:

mat420
05-14-2008, 03:08 PM
maybe not. this works but..its for a site that sells brochures, these brochures have many different options


if i do an "if this do that" for every option, itll take forever and get confusing. what else can i do?


these broshires have say, 3 dif thicknesses, then 3 different fold options, 3 different color options and say ...3 different size options. what can i do to make this easier?

binaryWeapon
05-15-2008, 12:41 AM
TBH, I don't really know of a better solution. You're going to have to type out 81 or so if-then statements, if you have different links for each combination. A possible solution would be to give a series of pages names that correspond to a combination of options selected. For example, if you selected: "medium","trifold","green","large", as the options for thicknesses, fold options, colors and sizes, then it would take you to a page called "mediumtrifoldgreenlarge.html"... in this situation you would now have to make 81 html pages. The thing I would do would be to have a php page that would take 4 _GET vars in the url. You would then set up a (java)script like:
document.location="phppage.php?thickness="+obj1+"&fold="+obj2+"&color="+obj3+"&size="+obj4;
So looking back, it would appear that unless you can pass the values right to the shopping cart or whatever you're using, you will have to have 81 of something. It depends on your situation and what you can work with.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum