Selamat Malam,
Saat ini saya membuat web aplication untuk pengajuan kredit, namun saya ada kendala membuat combobox dinamis untuk jenis kredit, merk barang dan tipe barang, mohon bantuannya.
<?php
include("koneksi.php");
?>
<head>
<title>Form Pengajuan Kredit</title>
<script type="text/javascript" src="js/jqueryy.js"></script>
<script type="text/javascript">
var htmlobjek;
$(document).ready(function() {
$("#kredit").change(function() {
var kredit = $("#kredit").val();
$.ajax({
url : "ambilmerk.php",
data : "id_kredit="+id_kredit,
cache : false,
success : function(msg){
$("#merk").html(msg);
}
});
});
$("#merk").change(function(){
var merk = $("#merk").val();
$.ajax({
url : "ambiltipe.php",
data : "id_merk="+id_merk,
cache : false,
success :function(msg){
$("#tipe").html(msg);
}
});
});
});
</script>
</head>
<html>
<body>
<p>
<div id='header'>
<div id='isi'>
<form action='simpan_permohonan.php' method='post'>
<fieldset>
<center>
<table>
<tr>
<td colspan='2' align='center' ><h1>Formulir Pengajuan Kredit </h1></td>
</tr>
<p align='center' class='style6 style7'><img src='images/mega.jpg' class='gambar'></p>
<tr>
<td>Nama Lengkap</td>
<td><input type='text' name='nama' size='50' /></td>
</tr>
<tr>
<td>Nomor Identitas</td>
<td><input type='text' name='no_id' size='50' /></td>
</tr>
<tr>
<td>Jenis Kelamin</td>
<td><label><input type='radio' name='jenis' value='Laki Laki' />Laki-Laki</label>
<label><input type='radio' name='jenis' value='Perempuan' />Perempuan</label></td>
<script>
var radio = document.getElementsByName('jenis');
var jenis = '';
for (var i = 0, length = radio.length; i < length; i++) {
if (radio[i].checked) {
jenis = radio[i].value;
}
}
</script>
</tr>
<tr>
<td>Pekerjaan</td>
<td><input type='text' name='pekerjaan' size='50' /></td>
</tr>
<tr>
<td>Agama</td>
<td><select name='agama'>
<option>Pilih Agama</option>
<option>Islam</option>
<option>Kristen Katolik</option>
<option>Kristen Protestan</option>
<option>Hindu</option>
<option>Bhudha</option>
<option>Kong Khuchu</option>
</select>
</td>
</tr>
<tr>
<td>Email</td>
<td><input type='text' name='email' size='50' /></td>
</tr>
<tr>
<td>Telepon</td>
<td><input type='text' name='tlp' size='50' /></td>
</tr>
<tr>
<td>Alamat</td>
<td><textarea name='alamat' cols='52' rows='5'> </textarea></td>
</tr>
<tr>
<td>Nama Perusahaan</td>
<td><input type='text' name='kantor' size='50' /></td>
</tr>
<tr>
<td>Jabatan</td>
<td><input type='text' name='jabatan' size='50' /></td>
</tr>
<tr>
<td>Lama Bekerja </td>
<td><input type='text' name='lama_kerja' size='50' /></td>
</tr>
<tr>
<td>Alamat Perusahaan</td>
<td><textarea name='alamat_ktr' cols='52' rows='5'> </textarea></td>
</tr>
<tr>
<td>Telp Perusahaan </td>
<td><input type='text' name='tlp_ktr' size='50' /></td>
</tr>
<tr>
<td>Jenis Kredit</td>
<td><select name="kredit" id="kredit" class="form-control">
<option>--Pilih Jenis Kredit--</option>
<?php
$kredit = mysql_query("SELECT * FROM kredit ORDER BY jenis_kredit");
while($p=mysql_fetch_array($kredit)){
echo "<option value=\"$p[id_kredit]\">$p[jenis_kredit]</option>\n";
}
?>
</tr>
</td>
</select>
<tr>
<td>Merk Barang</td>
<td><select name="merk" id="merk">
<option>--Pilih Merk Barang--</option>
<?php
$kredit = mysql_query("SELECT * FROM merk ORDER BY merk_barang");
while($p=mysql_fetch_array($kredit)){
echo "<option value=\"$p[id_merk]\">$p[merk_barang]</option>\n";
}
?>
</tr>
</td>
</select>
<tr>
<td>Tipe Barang</td>
<td><select name="tipe" id="tipe">
<option>--Pilih Tipe Barang--</option>
<?php
$merk = mysql_query("SELECT * FROM tipe ORDER BY tipe_barang");
while($p=mysql_fetch_array($merk)){
echo "<option value=\"$p[id_tipe]\">$p[tipe_barang]</option>\n";
}
?>
</tr>
</td>
</select>
<tr>
<td>Harga Barang </td>
<td><input type='text' name='harga' size='25' /></td>
</tr>
<tr>
<td>DP </td>
<td><select name='dp'>
<option>Pilih Uang Muka</option>
</select>
</td>
</tr>
<tr>
<td>Tenor </td>
<td><select name='tenor'>
<option>Pilih Tenor</option>
</select>
</td>
</tr>
<tr>
<td>Angsuran </td>
<td><select name='angsuran'>
<option>Angsuran Perbulan</option>
</select>
</td>
</tr>
<tr>
<td colspan='2' align='right'><input type = 'submit' name = 'daftar' value = 'Simpan' /></td>
</tr>
</table>
</center>
</fieldset>
</form>
</div>
</div>
</p>
</body>
</html>