Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing jQuery to detect value of one drop down and update another
    primarykey
    data
    text
    <p>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!</p> <p>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. </p> <p>The HTML:</p> <pre><code>&lt;form class="custom"&gt; &lt;div class="large-6 columns"&gt; &lt;label for="IndustryDropDown"&gt;Area of interest&lt;/label&gt; &lt;select id="IndustryDropDown" class="small"&gt; &lt;option&gt;All&lt;/option&gt; &lt;option&gt;Technology&lt;/option&gt; &lt;option&gt;Services&lt;/option&gt; &lt;option&gt;Financial&lt;/option&gt; &lt;option&gt;Consumer goods&lt;/option&gt; &lt;option&gt;Materials and mining&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class="large-6 columns"&gt; &lt;label for="SubIndustryDropDown"&gt;Specific interest&lt;/label&gt; &lt;select id="SubIndustryDropDown" class="small"&gt; &lt;option&gt;Select Area first&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>The JS:</p> <pre><code>$("#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") } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload