Q:

jQuery $.each() - Array of Objects

I am trying to perform jQuery each function on something like:
"RelatedDoc": [
    {
        "Id": "test",
        "Number": "26262316"
    }
],

Which is a part of a large JSON object. So far I have:
$.each($('#panel_MRD').data('obj'), function (key,value) {
    $('select.mrdDisplayBox').addOption( key, value, false);
});

I am trying to get the option to display "ID - NUMBER" - Any ideas? The above displays but not the right format.

A:

$.each(largeJSONobject.ReleatedDoc, function (index,value) {
    $('select.mrdDisplayBox').addOption(value.Id, value.Id + ' - ' + value.Number, false);
});

Your value is the single element from your array: { Id: '', Number: '' }
Documentation is here: http://api.jquery.com/jQuery.each/

A:

Here is my problem and what i solved.
Use firebug.
this is Array Object. Which is use to create four check boxes.
[
    {"datamet":"1","vchAmenityName":"TV"},
    {"datamet":"2","vchAmenityName":"Cable TV"},
    {"datamet":"5","vchAmenityName":"Internet"},
    {"datamet":"7","vchAmenityName":"Air Conditioning"}
]

<input type="checkbox" value="1" id="datamet1" />
<input type="checkbox" value="2" id="datamet2" />
<input type="checkbox" value="5" id="datamet5" />
<input type="checkbox" value="7" id="datamet7" />

i have to find this inside first. Means to check the element inside it like below
[{"datamet":"2"}]
For this i did following .. i got the problem solved
$.each(result, function(idx, obj){ 
    $.each(obj, function(key, value){
        console.log(key + ": " + value);
    });
});

A:

$.each($('#panel_MRD').data('obj'), function (key,value) {
    $('select.mrdDisplayBox').addOption( value.Id, value.Id + ' - ' + value.Number, false);
});

