Link to home
Start Free TrialLog in
Avatar of skranch
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","greyhound");
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.the_examples;
  var the_array = eval(the_array_name);
  setOptionText(window.document.the_form.the_examples, the_array);
}

function setOptionText(the_select, the_array)
{
  for (loop=0; loop < the_select.options.length; loop++)
  {
    the_select.options[loop].text = the_array[loop];
  }
}
</script>
               
</head>

<body bgcolor="#ffffff">
     
<b>My favorite animal is ...</b>

<form name="the_form">
<select name="choose_category" onChange="swapOptions(window.document.the_form.choose_category.options[selectedIndex].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>
ASKER CERTIFIED SOLUTION
Avatar of jonnal
jonnal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jaysolomon
jaysolomon

*******************************************************
******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