php - combo box with countries as its id, and an input text that will do the autocomplete -


i made combo box contain country it's id, , have input text autocomplete. if select 1 of country combo box, want input text show me, when press words autocomplete function, of city include in country (assuming have in database).

sample code below

form


          city:            <select name="city" id="city" />              <option value="">-- first select state --</option>               <option value="">bangalore</option>              <option value="">mumbai</option>              <option value="">chennai</option>              <option value="">gujrath</option>           </select>            area :             <input id="loction" name="loction" type="text" />     script    --------           $(document).ready(function() {             $("#loction").autocomplete("get_course.php",                           {                            extraparams: {                            country: function() { return $("#city").val(); }                            }                 });             }); 

mysql[get_course.php]


       require_once "connection.php";    $q = strtolower($_get["q"]);    if (!$q) return;      $cty = $_get["city"];          $sql = "select distinct area area                      table_name                     area '%$q%' ,    city = '".$cty."' ";            $rsd = mysql_query($sql);           while($rs = mysql_fetch_array($rsd))               {     $cname = $rs['area'];     echo "$cname\n";              } 

in get_course.php try search pattern out of array element $_get["city"] in extraparams data structure, send using autocomplete, define object name country. mistake?

try evaluating array element $_get["country"]:

$cty = $_get["country"]; $sql = "select distinct area table_name "       ."where area '%$q%' , city ='$cty'"; 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -