am trying to set listbox values as selected based on the value obtained from json
My problem is while putting static data am getting that values as selected.
please look at this
http://jsfiddle.net/9Stxb/89/
But in the above code if my json data change, the above selection will not correct.this will be sometimes val1,val2,val3 or any combination .
i used following code
but it is not working.. http://jsfiddle.net/9Stxb/91/
code
var myData ={
"_id": "525f8226360cc02c2bd63dec",
"id": "30",
"jobs": [{
"_id": "524a4f4cc973602da0d4ee10",
"id": "4",
"launch": "mypraram val url",
"names": "val1",
}, {
"_id": "525f6deb360cc02c2bd63dea",
"id": "28",
"launch": "jithinurl",
"names": "val2"
}],
"server": "180.16.17.60"
}
$(function() {
for(x in mydata.jobs){ $('#jobSel').val(['mydata.jobs[x].names','mydata.jobs[x].names']);
}
});
html
<div class="id_100">
<select id="jobSel" class="longcombo" multiple>
<option value="val1">Val 1</option>
<option value="val2">Val 2</option>
<option value="val3">Val 3</option>
</select>
</div>