i want to make a multi selection one is depend to another. when i select fruit then it show three option banana orange aple then select banbana it show another option red orange yellow.But problem show in red orege yellow so third type i face problem
<html>
<head>
</head>
</body>
<select name="select1" id="select1">
<option value="1">Fruit</option>
<option value="2">Animal</option>
<option value="3">Bird</option>
<option value="4">Car</option>
</select>
<select name="select2" id="select2">
<option value=""></option>
<option value="1">Banana</option>
<option value="1">Apple</option>
<option value="1">Orange</option>
<option value="2">Wolf</option>
<option value="2">Fox</option>
<option value="2">Bear</option>
<option value="3">Eagle</option>
<option value="3">Hawk</option>
<option value="4">BWM<option>
</select>
// here is my problem
<select name="select3" id="select3">
<option value=""></option>
<option value="1">red</option>
<option value="1">orange</option>
<option value="1">yellow</option>
<option value="2">white</option>
<option value="2">gray</option>
<option value="2">blue</option>
<option value="3">ash</option>
<option value="3">silver</option>
<option value="4">gold<option>
</select>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/function.js"></script>
<script type="text/javascript">
$("#select1").change(function() {
if($(this).data('options') == undefined){
/*Taking an array of all options-2 and kind of embedding it on the select1*/
$(this).data('options',$('#select2 option').clone());
}
var id = $(this).val();
var options = $(this).data('options').filter('[value=' + id + ']');
$('#select2').html(options);
});
$("#select2").change(function() {
if($(this).data('options') == undefined){
/*Taking an array of all options-2 and kind of embedding it on the select1*/
$(this).data('options',$('#select3 option').clone());
}
var id = $(this).val();
var options = $(this).data('options').filter('[value=' + id + ']');
$('#select3').html(options);
});
</script>
</body>
</html>