i have two drop downs. first drop down populate from database. second drop down populated from database based on selected value of first drop down.
if want to add options to the second drop down you need to use append not html and your using same ID i.e. #c to write the response in ajax success, change it to second drop down ID i.e. #s
you can try this:
$(document).ready(function() {
$("#c").change(function() {
var c1 = $('#c :selected').text();
if(c1 != "") {
$.ajax({
url:'getstatw.php',
data:{c:c1},
type:'POST',
success:function(response) {
var resp = $.trim(response);
$("#s").append(resp);
}
});
} else {
$("#c").append("");
}
});
});
then remove , in insert query.
$sql1="INSERT INTO table1 (Country, State)
VALUES ('$c', '$s')";