Note that there are some explanatory texts on larger screens.

plurals
  1. POjson jquery iteration
    primarykey
    data
    text
    <p>iam newbie here.. please execuse if iam asking wrong question here. iam developing dynamic page having two drop down boxes in which second automatically refreshed based on selection of value from first drop down.iam using jquery $.html to automatically refresh second drop down.</p> <pre><code>$("#subcategory").html('&lt;select name="sub_category" class="valid" id="subcategory"&gt;&lt;option&gt;Art - Classes&lt;/option&gt;&lt;option&gt;Beautician Courses&lt;/option&gt;&lt;option&gt;Computer - Multimedia Classes&lt;/option&gt;&lt;option&gt;Cooking - Classes&lt;/option&gt;&lt;option&gt;Hobby - Classes&lt;/option&gt;&lt;option&gt;Language Classes&lt;/option&gt;&lt;option&gt;Motor driving - Classes&lt;/option&gt;&lt;option&gt;Music - Theatre - Dance Classes&lt;/option&gt;&lt;option&gt;Professional courses - tutions&lt;/option&gt;&lt;option&gt;Summer - Camps&lt;/option&gt;&lt;option&gt;Training Instutions&lt;/option&gt;&lt;option&gt;Tutoring - Private Lessons&lt;/option&gt;&lt;option&gt;Other Classes&lt;/option&gt;&lt;/select&gt;').show(); </code></pre> <p>instead of above one i would like to try with json object and populate second drop down. my json data will be as below:</p> <pre><code>var data = { cat_1: { {"id": "1", "sub_cat": "sub1"}, {"id":"2", "sub_cat":"sub2"} }, cat_2: { {"id": "3", "sub_cat": "sub3"}, {"id":"4", "sub_cat":"sub4"} } }; </code></pre> <p>if user selects category 1 second drop down should populate value from cat_1.</p> <p>iam using below code. but i dont know where to restrict or filter based on selection from first drop down</p> <pre><code> $.each(data, function(index, array,array1) { // options[options.length] = new Option(array['variety']); options[options.length] =new Option(array['id'],array['sub_cat']); </code></pre>
    singulars
    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