kasusnya sederhana tpi blm ktemu jga ni solusinya mohon bntuannya bli..
dalam form transaksi ada 2 combobox
1.combobox 1 menampilkn type kartu kredit yang akn d pakai
2 combobox 2 menampilkan tempat konsumen melakukan gesek kartu kredit
sya pke scrip ini bsa tampil untuk combobox 1 tpi untuk yang ke2nya g bsa tampil mohon dengan sangat bntuannya dri para master php
<?php
mysql_connect("localhost","root","");
mysql_select_db("dbgestun");
$result = mysql_query("select * from edc");
$jsArray = "var prdName = new Array();\n";
echo 'Kode EDC : <select name="prdId" onchange="changeValue(this.value)">';
echo '<option>--Silahkan Pilih --</option>';
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['id_edc'] . '">' . $row['id_edc'] . '</option>';
$jsArray .= "prdName['" . $row['id_edc'] . "'] = {name:'" . addslashes($row['nama_edc']) . "',desc:'".addslashes($row['bankRT_trans'])."'};\n";
}
echo '</select>';
?>
Nama EDC Machine : <input type="text" name="nama_edc" id="nama_edc"/>
Bankrate : <input type="text" name="bankRT_trans" id="bankRT_trans"/>
<script type="text/javascript">
<?php echo $jsArray; ?>
function changeValue(id){
document.getElementById('nama_edc').value = prdName[id].name;
document.getElementById('bankRT_trans').value = prdName[id].desc;
};
</script>
saya jga coba ini tetep g bsa tmpil untuk combobox yg ke2
<?php
$koneksi=mysql_connect("localhost","root","") or die (mysql_error());
$pilih_db=mysql_select_db("dbgestun") or die (mysql_error());
$perintah="SELECT * FROM krt_kredit";
$jalankan_perintah=mysql_query($perintah) or die (mysql_error());
$result = mysql_query("select * from krt_kredit");
$jsArray = "var card_type = new Array();\n";
echo '<select name="card_type" onchange="document.getElementById(\'no_credit\').value = card_type[this.value]">';
echo '<option>-------</option>';
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['card_type'] . '">' . $row['card_type'] . '</option>';
$jsArray .= "card_type['" . $row['card_type'] . "'] = '" . addslashes($row['no_credit']) . "';\n";
}
echo '</select>';
?>
Bankrate : <input type="text" name="no_credit" id="no_credit"/>
<script type="text/javascript">
<?php echo $jsArray; ?>
</script>