JQuery

<script>
$(document).ready(function(){

$(“#htmlform”).validate();

$(“#disrtict”).change(function()
{
var disrtict = $(‘#disrtict’).val();
//alert(disrtict);

if(disrtict != 0)
{
$.ajax({
type: “POST”,
url: “getdata.php”,
data: {id:disrtict}
}).done(function( result ) {
//alert(result)
$(“#city”).html(result);
});
}
});
});

</script>

 

 

————————————————————————————————————–

Getdata.php File

<?php
error_reporting(0);
require(‘db.class.php’);

$id = $_POST[‘id’];
$sql = “SELECT * from tbl_city where dis_id=”.$id;
$result = mysql_query($sql);

echo ‘<select name=”city” id=”city”>’;
echo ‘<option value=”0″>– Select City –</option>’;
while($row = mysql_fetch_array($result))
{
echo ‘<option value=”‘.$row[‘id’].'”>’.$row[‘city’].'</option>’;
}
echo ‘</select>’;

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: