jquery - Populate select input from json data that have different keys -
i got these data return php script in json format.
{ "inherited_items":{1:"role num1",2:"role num2",3:"role num3"}, "available_items":{4:"role num4",6:"role num5",6:"role num6"} } how set values options select input? came question " jquery getjson populate select menu question", solution not work me. because json data have not have uniform index array values. there way set data option values out reformatting json data php script. index of arrays important me.
by way, json data have used populate 2 different select input.
to populate select element id test data inherited_items
$.each(data.inherited_items, function(key, value){ $('<option />', { value: key, text: value }).appendto('#test') }); demo: fiddle
Comments
Post a Comment