it's my first weekend with Javascript (coming from a Matlab background) and after an amazingly productive Saturday I've been stuck on this for hours, any help very much appreciated!
I'm trying to detect the value of one Drop down box and then update another from the Parse backend, one is top level industries the other is sub-industries. This seems like it should be pretty easy from the other answers on here but whilst it detects the change it never actually updates the second box. The data arrives fine from Parse. I'm using the Foundation framework, latest version of jQuery and Handlebars in other parts if that could make a difference.
The HTML:
<form class="custom">
<div class="large-6 columns">
<label for="IndustryDropDown">Area of interest</label>
<select id="IndustryDropDown" class="small">
<option>All</option>
<option>Technology</option>
<option>Services</option>
<option>Financial</option>
<option>Consumer goods</option>
<option>Materials and mining</option>
</select>
</div>
<div class="large-6 columns">
<label for="SubIndustryDropDown">Specific interest</label>
<select id="SubIndustryDropDown" class="small">
<option>Select Area first</option>
</select>
</div>
</form>
The JS:
$("#IndustryDropDown").change(function(){
var SubIndustry = Parse.Object.extend("SubIndustry");
var query = new Parse.Query(SubIndustry);
// change this to a case statement once working
if ($(this).val() == "Technology"){
var Industries = Parse.Object.extend("Industries");
var industries = new Parse.Query(Industries);
query.descending("Name");
query.equalTo("Industry", "Technology")
query.find({
success: function(results) {
$(results).each(function(i,e) {
var q = e.toJSON();
console.log(q.Name) // this prints out the Name entries as expected
$('SubIndustryDropDown').append( new Option(q.Name, q.Name));
});//for each
},//sucess
error: function(error) {
console.warn("error finding quote")
}
});