Playing with selects and javascript

Posted by Tom on Stack Overflow See other posts from Stack Overflow or by Tom
Published on 2010-12-26T22:17:10Z Indexed on 2010/12/26 22:54 UTC
Read the original article Hit count: 139

Filed under:
|
|

My code is:

<select name='main'>
<option>Animals</option>
<option>Food</option>
<option>Cars</option>
</select>
<select name='other'>
<option>Rats</option>
<option>Cats</option>
<option>Oranges</option>
<option>Audi</option>
</select>

How do I filter my second select, so it would only show items which I want eg. if I Choose Animals, my select would be:

<select name='other'>
<option>Rats</option>
<option>Cats</option>
</select>

and if I choose Food, my select would be:

<select name='other'>
<option>Oranges</option>
</select>

Well, I hope you get the idea. Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery