javascript - Jquery Dependent Dropdown to load on document ready -
hello have depdent dropdown country sate , city , want load states , cities based on country on document ready function tried put document.ready (function())
but nothing works please update me how can use
my code here
function showstate(sel) { var country_id = sel.options[sel.selectedindex].value; $("#output1").html( "" ); $("#output2").html( "" ); if (country_id.length > 0 ) { $.ajax({ type: "post", url: "fetch_state.php", data: "country_id="+country_id, cache: false, beforesend: function () { $('#output1').html('<img src="images/loading.gif">'); }, success: function(html) { $("#output1").html( html ); } }); } } function showcity(sel) { var state_id = sel.options[sel.selectedindex].value; if (state_id.length > 0 ) { $.ajax({ type: "post", url: "fetch_city.php", data: "state_id="+state_id, cache: false, beforesend: function () { $('#output2').html('<img src="images/loading.gif">'); }, success: function(html) { $("#output2").html( html ); } }); } else { $("#output2").html( "" ); } }
you can try selectize.js @ "city / state selection" section.
Comments
Post a Comment