mas sesuai http://www.myphptutorials.com/questions/combo-box-tidak-muncul_865.html, aku buat perubahan untuk penyesuaian form, nah ini jsnya
<?php
mysql_connect ('localhost','root','rahasia');
mysql_select_db ('abms');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$tipedata = $_POST['tipe'];
$id = $_POST['id'];
switch($tipedata){
case 'unit':
$sql='SELECT kode_unit,nama_unit,produk FROM '.$tipedata.' WHERE kodeP = "'.$id'" ORDER BY nama_unit ASC';break;
case 'produk':
$sql='SELECT kodeP,produk FROM '.$tipedata.' ORDER BY produk ASC';break;
}
$kueri=mysql_query($sql);
echo '<option value=""></option>';
while($row=mysql_fetch_object($kueri)){
echo '<option value="'.$row->kodeP.'">';
switch($tipedata){
case 'unit':
echo $row->nama_unit;break;
case 'produk':
echo $row->produk;break;
}
echo '</option>';
}
}
?>
dan ini formnya
<script language="javascript">
function Load(data,primid){
$('#loading'+data).empty().append('<img src="img/ajax-loader.gif"/>');
$.post("js_unit.php",{tipe:data,id:primid},
function(result){
$('#cb'+data).html(result);
$('#loading'+data).empty();
}
);
}
$(function(){
Load('produk',0);
$('#cbproduk').change(
function(){
if($('#cbproduk option:selected').val() !=''){
Load('unit',$('#cbproduk option:selected').val());
}
}
);
});
</script>
<tr title="Required">
<td><b>Produk</b><span class="required">*</span></td>
<td>:</td>
<td><select name="produk" id="cbproduk" style="width:311px"></select></td>
</tr>
<tr title="Required">
<td><b>Unit</b><span class="required">*</span></td>
<td>:</td>
<td><select name="nama_unit" id="cbunit" style="width:311px"></select></td>
</tr>