skranch
asked on
Javascript 'third' dynamic pulldown onChange
Hi there,
I found the working example below which is ok, but need to add a third pulldown menu that is changed based on the second pulldown menu - see more_examples field:
thanks
<html>
<head>
<script language="javascript">
var dogs = new Array("poodle","puli","gre yhound");
var fish = new Array("trout", "mackerel", "bass");
var birds = new Array("robin", "hummingbird", "crow");
function swapOptions(the_array_name )
{
var numbers_select = window.document.the_form.t he_example s;
var the_array = eval(the_array_name);
setOptionText(window.docum ent.the_fo rm.the_exa mples, the_array);
}
function setOptionText(the_select, the_array)
{
for (loop=0; loop < the_select.options.length; loop++)
{
the_select.options[loop].t ext = the_array[loop];
}
}
</script>
</head>
<body bgcolor="#ffffff">
<b>My favorite animal is ...</b>
<form name="the_form">
<select name="choose_category" onChange="swapOptions(wind ow.documen t.the_form .choose_ca tegory.opt ions[selec tedIndex]. text);">
<option selected>dogs
<option>fish
<option>birds
</select>
<select name="the_examples">
<option>poodle
<option>puli
<option>greyhound .
</select><select name="more_examples">
<option>poodletypea
<option>poodletypeb
<option>poodletypec
</select>
</form>
<p></p>
</body>
</html>
I found the working example below which is ok, but need to add a third pulldown menu that is changed based on the second pulldown menu - see more_examples field:
thanks
<html>
<head>
<script language="javascript">
var dogs = new Array("poodle","puli","gre
var fish = new Array("trout", "mackerel", "bass");
var birds = new Array("robin", "hummingbird", "crow");
function swapOptions(the_array_name
{
var numbers_select = window.document.the_form.t
var the_array = eval(the_array_name);
setOptionText(window.docum
}
function setOptionText(the_select, the_array)
{
for (loop=0; loop < the_select.options.length;
{
the_select.options[loop].t
}
}
</script>
</head>
<body bgcolor="#ffffff">
<b>My favorite animal is ...</b>
<form name="the_form">
<select name="choose_category" onChange="swapOptions(wind
<option selected>dogs
<option>fish
<option>birds
</select>
<select name="the_examples">
<option>poodle
<option>puli
<option>greyhound .
</select><select name="more_examples">
<option>poodletypea
<option>poodletypeb
<option>poodletypec
</select>
</form>
<p></p>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
******PLEASE DO NOT ACCEPT THIS COMMENT AS ANSWER******
**************************
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area:
RECOMMENDATION:
- [Points to jonnal Grade A]
Please leave any comments here within the next seven days.
**************************
******PLEASE DO NOT ACCEPT THIS COMMENT AS ANSWER******
**************************
jAy
EE Cleanup Volunteer