mas mau tanya lagi
<!DOCTYPE html>
<html lang="en">
<head>
<title>Jquery</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/flexslider.css">
<script language="javascript" src="jquery.js"></script>
<script language="javascript">
function Load(data,primid){
$('#loading'+data).empty().append('<img src="img/ajax-loader.gif"/>');
$.post("lokasi.php",{tipe:data,id:primid},
function(result){
$('#cb'+data).empty();
if(result.error==undefined){ //cek ada error atau ngga,klo ga ada lanjut
$('#cb'+data).append('<option>---Pilih Data---</option>');
for(var i=0;i<=result.length;i++){
$('#cb'+data).append($('<option></option>').val(result[i].id).text(result[i].nama));
}
}else{
$('#loading'+data).empty().append('Data tidak ditemukan');
//alert(result.error);
}
},'json'
);
$('#loading'+data).empty();
}
$(function(){
Load('provinsi',0);
$('#cbprovinsi').change(
function(){
if($('#cbprovinsi option:selected').val() !=''){
Load('lokasi',$('#cbprovinsi option:selected').val());
}
}
);
$('#cblokasi').change(
function(){
if($('#cblokasi option:selected').val() !=''){
Load('alamat',$('#cblokasi option:selected').val());
}
}
);
});
</script>
</head>
<body>
<!-- The template uses conditional comments to add wrappers div for ie8 and ie7 - just add .ie or .ie7 prefix to your css selectors when needed -->
<!--[if lt IE 9]><div class="ie"><![endif]-->
<!--[if lt IE 8]><div class="ie7"><![endif]-->
<!-- Header -->
<!-- Server status -->
<header><div class="container_12">
</div></header>
<!-- End server status -->
<!-- Main nav -->
<form class="block-content form" action="" method="post" id = "form_admin" name = "form_admin">
<h1>Location Management <a href=""><img src="images/icons/fugue/navigation-180.png" width="16" height="16"> Back</a></h1>
<div class="block-header">Register Location</div>
<div class="columns">
<div class="colx2-left">
<fieldset>
<legend>Profile</legend>
<table cellpadding="3" class="table-padding">
<tr title="Required">
<td><b>Provinsi</b><span class="required">*</span></td>
<td>:</td>
<td><select id="cbprovinsi"></select></td>
</tr>
<tr title="Required">
<td><b>Location</b><span class="required">*</span></td>
<td>:</td>
<td><select id="cblokasi"></select></td>
</tr>
<tr title="Required">
<td><b>Alamat</b><span class="required">*</span></td>
<td>:</td>
<td><select id="cbalamat"></select></td>
</tr>
</table>
</fieldset>
</div>
</div>
<div class="block-footer" style="height:30px;">
<div class="float-right">
<button type="submit"><img src="images/icons/fugue/tick-octagon.png" name = "save" id ="save" onclick="saveForm(); return false;" width="16" height="16"> Save</button>
<button type="reset" class="grey" onclick="this.form.reset();"><img src="images/icons/fugue/arrow-circle.png" width="16" height="16"> Reset</button>
<button type="reset" class="red" onclick="document.location.href='http:register.php';"><img src="images/icons/fugue/cross-white.png" width="16" height="16"> Cancel</button>
</div>
</div>
</form>
<br>
<p>
<span class="required">*</span> Required</p>
</div></div>
</section>
<div class="clear"></div>
</body>
</html>
nah ini lokasi.phpnya
<?php
$conn=mysql_connect('localhost','root','');
mysql_select_db('',$conn);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$tipedata=$_POST['tipe'];
$id=$_POST['id'];
switch($tipedata){
case 'alamat':
$sql='SELECT kode,alamat FROM '.$tipedata.' WHERE kode_lokasi = "'.$id.'" ORDER BY alamat ASC';break;
case 'lokasi':
$sql='SELECT kode,lokasi FROM '.$tipedata.' WHERE kode_provinsi = "'.$id.'" ORDER BY lokasi ASC';break;
case 'provinsi':
$sql='SELECT kode,provinsi FROM '.$tipedata.' ORDER BY provinsi ASC';break;
}
$res = array(); //reson variable yang akan digunakan
/*if ($tipedata != 'provinsi'){
$res['error']='error : '.$sql;
die(json_encode($res));
}*/
$kueri=mysql_query($sql);
if($kueri){
if(mysql_num_rows($kueri) > 0){
while($row=mysql_fetch_object($kueri)){
$res[]=$row;
}
}else{
$res['error']='Data tidak ditemukan';
}
}else{
$res['error']='error server : '.mysql_error();
}
}
die(json_encode($res));
?>
nah kalo databasenya
provinsi
1.kode
2.provinsi
lokasi
1.kode
2.lokasi
3.kode_provinsi
alamat
1.kode
2.alamat
3.kode_alamat
terima kasih mas