Click to See Complete Forum and Search --> : Simple pulldown-question...
maw_webdesign
01-31-2003, 05:18 AM
Hi there...
I have 3 pulldown menus and now I'd like to know I can set a variable when the pulldown menus are selected.
Something like this:
When (pulldown1 = a) AND (pulldown = 14) AND (pulldown3 = Leon) variable Title = "Webmaster"
Can anyone give this newbie a clue?
Thanx...
You can do it by using something like this:
<script language="JavaScript">
<!--
function proofs(x)
{
pointer = 0;
prof = new Array ("pulldown1","pulldown2","pulldown3"); // your pulldown-names;
valuess = new Array ("10","12","14"); // required values for creating the new var;
for(i=0;i<3;i++)
{
if(x.elements[prof[i]].value == valuess[i])
{
title = "Webmaster";
pointer++;
}
}
if(pointer==3)alert(title);
}
//-->
</script>
<body text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000">
<form name=myForm action="">
<select name="pulldown1" onChange="proofs(this.form)">
<option value="0">choose
<option value="10">Webmaster
</select>
<select name="pulldown2" onChange="proofs(this.form)">
<option value="0">choose
<option value="12">is
</select>
<select name="pulldown3" onChange="proofs(this.form)">
<option value="0">choose
<option value="14">good
</select>
</form>
</body>
gil davis
01-31-2003, 06:41 AM
<head>
<script>
function test(it) {
title = "wannabe";
si1 = it.pulldown1.selectedIndex;
si2 = it.pulldown.selectedIndex;
si3 = it.pulldown3.selectedIndex;
pd1 = it.pulldown1;
pd2 = it.pulldown;
pd3 = it.pulldown3;
if ((pd1.options[si1].value == "a") && (pd2.options[si2].value == "14") && (pd3.options[si3].value == "Leon"))
{title = "Webmaster";}
alert(title);
}
</script>
</head>
<body>
<form onsubmit="return false">
<select name="pulldown1">
<option>Pull Down 1
<option value="a">a
</select>
<select name="pulldown">
<option>Pull Down 2
<option value="14">14
</select>
<select name="pulldown3">
<option>Pull Down 3
<option value="Leon">Leon
</select>
<br><input type="button" onclick="test(this.form)" value="Test">
</form>
</body>
maw_webdesign
01-31-2003, 07:14 AM
It's working...