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.
Here is my problem and what i solved. Use firebug. this is Array Object. Which is use to create four check boxes.
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
Your value is the single element from your array: { Id: '', Number: '' }
Documentation is here: http://api.jquery.com/jQuery.each/
option 1 (this uses the
key
as the option 'id' i.e. 1, 2, 3 etc):have not tested, so potentially rushed answer.
[edit] - had a quick look back at this as i realised that there are potentially 2 values that you could use as the option 'id', either key or value.Number.
option 2 (this uses
value.Number
as the option 'id' i.e. 26262316):will stop thinking now... :-)