i have this json feed:
{
    "channel": {
        "title": "History",
        "id": "12",
        "subtopics": [
                        {"title": "Roman History", "ID","13"},
                        {"title": "Greek History", "ID", "1"},
                        {"title": "French History", "ID", "1"}
        ] // subtopics
    }
}

and i want to populate a select box to result as follows:

<option>History>
<optgroup>
<option value="ID">Roman History</option>
...
</optgroup>
</option>

this is the code i have so far:

$.getJSON("jrss.js", function(json) {
                var html = '<select id="select-program">';
                        response = {
                 values: [],
                 count: 0
             }; 
                $.each(json.channel.subtopics,function(i,item) {
                        html += '<option>history</option>'; // not sure where 
this goes 
                        response.values[i] = item.title;
                        html += '<optgroup>';
                        html += '<option>'+item.title;+'</option>';
                        html += '</optgroup';
                });
        
                        html += '</select>';

                        $('body').append(html);
                });
        
});

var jJSON = {
    getValues: function(obj,num) {
        return jJSON[obj]["values"];
    }
}


I can currently get the code to populate the <optgroup> correctly. I still
cannot get it to assign id as the value. and i cannot dynamically assign the
<option>history</history> dynamically...it returns undefined.

can anyone help me with these two issues? thanks
-- 
View this message in context: 
http://www.nabble.com/populate-selectbox-with-json-feed...partially-working%2C-need-help-to-finish.-tp20654600s27240p20654600.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to