Pushing data into a select based on the input of another select
I'm trying to push values into the breed drop down based on the input
selected in the first select. I have the all the data needed. I just don't
know how to push it into the select. The data is accessed by
breed_data.dog, breed_data.cat and so on. So initially I made an each loop
inside of the change function. I don't know where to begin, any tips would
be greatly appreciated.
<form id="filter" class="filter"
action="http://dev/petlist/public/site/index" accept-charset="utf-8"
method="post">
<select name="petsDropDown" id="form_petsDropDown">
<option value="allPets">All Pets</option>
<option value="barnyard">Barnyard</option>
<option value="bird">Bird</option>
<option value="cat">Cats</option>
<option value="dog">Dogs</option>
<option value="horse">Horse</option>
<option value="pig">Pigs</option>
<option value="smallfurry">Smallfurry</option>
</select>
<select name="breedDropDown" id="form_breedDropDown">
<option value="select_breed">Select Breed</option>
</select>
</form>
$(function(){
$('#form_petsDropDown').change(function(){
$('#form_breedDropDown').prop('disabled',($(this).val()=='allPets'));
$(breed_data).each(function() {
/*console.log(breed_data.dog);
console.log(breed_data.cat);
console.log(breed_data.smallfurry);
console.log(breed_data.bird);
console.log(breed_data.pig);
console.log(breed_data.horse);*/
});
}).change();
});
No comments:
Post a Comment