MemoryRefresh!

Combobox related



Questions Answers 0%

Pages   0 from 18
Questions   0 from 23

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="https://code.jquery.com/jquery-1.10.2.js"></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>
Questions

Related pages

Request !
Ajax post !
Ajax cross domain !
Autocomplete !
Combobox related !


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




Last Review: n/a   Passed: n/a   Reviews: n/a   Next Review: n/a  



<?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="https://code.jquery.com/jquery-1.10.2.js"></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>



More from Jquery

Attributes
Data
Effects
Window
Element
Basics
Ajax
Form
Uncategorized


More from Programming

Php
jQuery




Powered by minte9.com