select chained not showing in $_post method
Posted: Mon Feb 24, 2014 8:39 pm
anyone please help me. i try to showing selected option value from mysql.
i have 2 selected option,first is showing data from mysql.after the first one got selected,the second one will refer id from the previously. it means,all 2 select option are connected.but when i selected the the first,my second selected value not showing. i use $_POST method to call value.
i give my code bellow
This is my main form.
this file use to call value.
i have 2 selected option,first is showing data from mysql.after the first one got selected,the second one will refer id from the previously. it means,all 2 select option are connected.but when i selected the the first,my second selected value not showing. i use $_POST method to call value.
i give my code bellow
This is my main form.
Code: Select all
<html>
<head>
<title>Load Data Customer</title>
<script language="javascript" src="jquery.js"></script>
<script>
$(document).ready(function(){
$('#customer').change(function(){
var customer = $(this).val();
$.ajax({
type: 'POST', // Metode pengiriman data menggunakan POST
url: 'customer.php', // File yang akan memproses data
data: 'nama_customer=' + customer, // Data yang akan dikirim ke file pemroses
success: function(response) { // Jika berhasil
$('#person').html(response); // Berikan hasil ke id kota
}
});
});
</script>
</head>
<body>
<table>
<tr>
<td valign=top>Customer </td><td>
<select name="customer" id="customer" class="normal-select">
<option selected>- Pilih Customer -</option>
<?php
include "connect.php";
$tampil="SELECT * FROM customparent";
if ($res = mysql_query($tampil)) {
while ($row = mysql_fetch_array($res)) {
echo "<option value=’$row[id]‘>$row[customer]</option>";
}
}
?>
</select>
</td>
</tr>
<tr>
<td>Person</td>
<td><select name="person" id="person" class="normal-select">
<option selected>- Pilih Person -</option>
</select>
</td>
</tr>
</body>
</html>
Code: Select all
<?php
include "connect.php";
$tampil="SELECT * FROM customchild WHERE id='$_POST[nama_customer]'";
$option= '';
if($tampil = mysql_query ($tampil)) {
while($r=mysql_fetch_array($tampil)){
$option.= "<option value=\"$r[id]\">$r[person]</option>";
}
echo '<select name="person">'.$option.'</select>';
}
?>