mas aku mau tanya sedikit, kan ceritanya aku udah bisa combo box nih, nah aku lagi coba data di combo box ini setelah di tampilkan akan diinsert ke tabel lain.
<!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("lo.php",{tipe:data,id:primid},
function(result){
$('#cb'+data).html(result);
$('#loading'+data).empty();
}
);
}
$(function(){
Load('propinsi',0);
$('#cbpropinsi').change(
function(){
if($('#cbpropinsi option:selected').val() !=''){
Load('lokasi',$('#cbpropinsi 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="set.php" 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>Propinsi</b><span class="required">*</span></td>
<td>:</td>
<td><select id="cbpropinsi" name="propinsi" ></select></td>
</tr>
<tr title="Required">
<td><b>Location</b><span class="required">*</span></td>
<td>:</td>
<td><select id="cblokasi" name="lokasi" ></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 lo.phpnya
<?php
mysql_connect ('localhost','','');
mysql_select_db ('java');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$tipedata = $_POST['tipe'];
$id = $_POST['id'];
switch($tipedata){
case 'lokasi':
$sql='SELECT kode,lokasi FROM '.$tipedata.' WHERE kode_pro = "'.$id.'" ORDER BY lokasi ASC';break;
case 'propinsi':
$sql='SELECT idProp,namaPropinsi FROM '.$tipedata.' ORDER BY namaPropinsi ASC';break;
}
$kueri=mysql_query($sql);
echo '<option value="">--- Select ---</option>';
while($row=mysql_fetch_object($kueri)){
echo '<option value="'.$row->idProp.'">';
switch($tipedata){
case 'lokasi':
echo $row->lokasi;break;
case 'propinsi':
echo $row->namaPropinsi;break;
}
echo '</option>';
}
}
?>
nah ini file prosesnya
<?php
mysql_connect ("localhost", "root", "rahasia");
mysql_select_db ("java");
$lokasi = $_GET['lokasi'];
$propinsi = $_GET['propinsi'];
$sql = "INSERT INTO hasil VALUES('$propinsi','$lokasi')";
mysql_query($sql) or die ('GAGAL');
?>
yang jadi masalah adalah pas di insert, di database hanya muncul di bagian propinsi sedangkan di bagian lokasi tetap kosong,
ini tabel hasil:
1. propinsi
2. lokasi
terima kasih bantuannya