I have SQLite table with columns id and name. I return array of those rows like json from autocomplete.php page. How to fill select with options ( drop down list ) with this
HTML:
JavaScript:
$(function() { var data = [ { "id": "1", "name": "test1"}, { "id": "2", "name": "test2"} ]; $.each(data, function(i, option) { $('#sel').append($('').attr("value", option.id).text(option.name)); }); })
Here's a working example. http://jsfiddle.net/ms2Ma/