function getCountyList(sel, sel_counties) { var fipsstate = $(sel).val(); var fipscounty = document.getElementById(sel_counties); $.ajax({ url: "json_getCounties.php", dataType: "json", data: "fipsstate=" + fipsstate, success: function(data) { createCounties(data, fipscounty); } }); } function createCounties(data, sel_counties) { $(sel_counties).children().remove(); $.each(data, function(index, value) { // alert(value['text'], value['value']); $(sel_counties).append(new Option(value['text'], value['value'])); }); }