MemoryRefresh!

Ajax / Combobox related     Combobox related



Questions Answers 0%

Pages   0 from 16
Questions   0 from 21

Reset



<?php if ($county = @$_GET['county']) { $arr = array( 'County_1' => array(0=>"", 11=>"City_11", 12=>"City_11"), 'County_2' => array(0=>"", 21=>"City_21", 22=>"City_22"), ); echo json_encode($arr[$county]); die; } ?> <form method="post"> <select id="county" onchange="setCity();"> <option> <option>County_1 <option>County_2 </select> <select name="city" id="city" disabled="disabled"> <option value="" label="City">City</option> </select> </form> <script src="code.jquery.com"></script> <script type='text/javascript'> function setCity(){ var county = $('select#county option:selected').val(); //alert(county); if (county) { $("#city option").each(function() { $(this).remove(); // -- Look Here -- // }); $('#city').removeAttr('disabled'); } $.get("test.php?county="+county, function (data){ var obj = jQuery.parseJSON(data); $.each(obj, function(key, val) { //console.log(key); $('#city').append($("<option></option>").attr("value",key).text(val)); // -- Look Here -- // }); }); } </script>

Related Pages

Request
Ajax post
Ajax cross domain
Autocomplete
Combobox related


0% 100%
 
 
0 pages 16 pages
1) Remove combobox options








<?php if ($county = @$_GET['county']) { $arr = array( 'County_1' => array(0=>"", 11=>"City_11", 12=>"City_11"), 'County_2' => array(0=>"", 21=>"City_21", 22=>"City_22"), ); echo json_encode($arr[$county]); die; } ?> <form method="post"> <select id="county" onchange="setCity();"> <option> <option>County_1 <option>County_2 </select> <select name="city" id="city" disabled="disabled"> <option value="" label="City">City</option> </select> </form> <script src="code.jquery.com"></script> <script type='text/javascript'> function setCity(){ var county = $('select#county option:selected').val(); //alert(county); if (county) { $("#city option").each(function() { $(this).remove(); // -- Look Here -- // }); $('#city').removeAttr('disabled'); } $.get("test.php?county="+county, function (data){ var obj = jQuery.parseJSON(data); $.each(obj, function(key, val) { //console.log(key); $('#city').append($("<option></option>").attr("value",key).text(val)); // -- Look Here -- // }); }); } </script>





Programming

Php
   
Regex
   
MySQL
   
Css
   
jQuery
   
Git
   


References
n/a