<?php
// koneksi mysql
mysql_connect('localhost', 'root', '');
mysql_select_db('aplikasi_pkl');
?>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.chained.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.chained.remote.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(function() {
/* For jquery.chained.js */
$("#series").chained("#mark");
$("#model").chained("#series");
$("#engine").chained("#series, #model");
/* Show button after each pulldown has a value. */
$("#engine").bind("change", function(event) {
if ("" != $("option:selected", this).val() && "" != $("option:selected", $("#model")).val()) {
$("#button").fadeIn();
} else {
$("#button").hide();
}
});
$("#c").chained("#a,#b");
/* For jquery.chained.remote.js */
$("#series-remote").remoteChained("#mark-remote", "json.php");
$("#model-remote").remoteChained("#series-remote", "json.php");
$("#engine-remote").remoteChained("#series-remote, #model-remote", "json.php");
/* Show button after each pulldown has a value. */
$("#engine-remote").bind("change", function(event) {
if ("" != $("option:selected", this).val() && "" != $("option:selected", $("#model-remote")).val()) {
$("#button-remote").fadeIn();
} else {
$("#button-remote").hide();
}
});
$("#c-remote").remoteChained("#a-remote,#b-remote", "json.php");
});
</script>
</head>
<body>
<h1>Demo</h1>
<form name="demo" method="post" action="submit.php">
<table>
<tr><td>Pilih Stream</td><td>:</td>
<td>
<select id="mark">
<option value="">--</option>
<?php
// query untuk menampilkan stream
$query = "SELECT * FROM STREAM";
$hasil = mysql_query($query);
while ($data = mysql_fetch_array($hasil))
{
echo "<option value='".$data['STREAM']."'>".$data['STREAM']."</option>";
}
?>
</select>
</td>
</tr>
<tr><td>Pilih Materi</td><td>:</td>
<td>
<select id="series">
<option value="">--</option>
<?php
// query untuk menampilkan materi
$query = "SELECT * FROM materi_training";
$hasil = mysql_query($query);
while ($data2 = mysql_fetch_array($hasil))
{
echo "<option value='".$data2['Kode_M']." class=".$data['STREAM']."'>".$data2['NAMA_M_TRAINING']."</option>";
}
?>
<option value="series-1" class="MKS">QWERTY</option>
<option value="series-3" class="BUS">ASDF</option>
</select>
</td>
</tr>
</table>
</form>
</body>
</html>
/* struktur tablenya
table stream
|stream|nama|tekhnik|
|MKS|MARKETING|NONTEKHNIK
|BUS|BUSINESS|NONTEKHNIK|
table materi_training
|KODE_M|STREAM|NAMA_M_TRAINING|
01 |MKS |manajement|
02 |BUS |Business PLAN|
*/