2 combobox dinamis

JulianS · Oct 17, 2012
permisi mau nanya. kan saya punya 2 combobox, nah setiap combo boxnya itu menampilkan data dari table yang berbeda. masalahnya disaat dijalankan hanya 1 combo box saja yang aktif dan bisa menampilkan data, tapi combox yang 1 lagi tidak aktif dan gk bisa nampilin data. tolong bantuan nya yaa.
	<?php include "koneksi.php" ?>
	<?php
	$result = mysql_query("select * from sales");
	$jsArray = "var slsName = new Array();\n";
	echo '<select name="slsId" onchange="changeValue(this.value)">';
	echo '<option>Pilih Nama Sales</option>';
	while ($row = mysql_fetch_array($result)) {
	echo '<option value="' . $row['id_sales'] . '">' . $row['nama_sales'] . '</option>';
	$jsArray .= "slsName['" . $row['id_sales'] . "'] = {ids:'".addslashes($row['id_sales'])."'};\n";
	}
	echo '</select>';
	?>

	<script type="text/javascript">
	<?php echo $jsArray; ?>
	function changeValue(id){
	document.getElementById('sls_id').value = slsName[id].ids;	
	};
	</script>
<input type="text" name="sls_name" id="sls_id"/>

<?php
	$result = mysql_query("select * from costumer");
	$jsArray = "var prdName = new Array();\n";
	echo '<select name="prdId" onchange="changeValue(this.value)">';
	echo '<option>Pilih Nama Company</option>';
	while ($row = mysql_fetch_array($result)) {
	echo '<option value="' . $row['id_costumer'] . '">' . $row['nama_costumer'] . '</option>';
	$jsArray .= "prdName['" . $row['id_costumer'] . "'] = {att:'".addslashes($row['attention'])."',alt:'" . addslashes($row['alamat']) . "',telp:'" . addslashes($row['telepon']) . "',psot:'".addslashes($row['posisi'])."',id:'".addslashes($row['id_costumer'])."'};\n";
	}
	echo '</select>';
	?>

	<script type="text/javascript">
	<?php echo $jsArray; ?>
	function changeValue(id){
	document.getElementById('cst_almt').value = prdName[id].alt;
	document.getElementById('cst_atte').value = prdName[id].att;
	document.getElementById('cst_telp').value = prdName[id].telp;
	document.getElementById('cst_psot').value = prdName[id].psot;
	document.getElementById('cst_id').value = prdName[id].id;
	};
	</script>
<input type="text" name="prod_name" id="cst_almt"/>
<input type="text" name="prod_desc" id="cst_atte"/>
<input type="text" name="prod_name" id="cst_telp"/>
<input type="text" name="prod_desc" id="cst_psot"/>
<input type="text" name="prod_name" id="cst_id"/>

terimakasih sebelumnya :)
Silahkan login untuk menjawab!
0
Loading...
JulianS · Oct 22, 2012 · 3 Suka · 3 Tidak Suka
Kok sepi :(
0
Loading...
Bayu Adindra · Oct 23, 2012 · 8 Suka · 8 Tidak Suka
 <form action="absen.php" method="post" target="POPUPW" onsubmit="POPUPW = window.open('about:blank','POPUPW','width=550,height=250');" id="dialog-link" class="ui-state-default ui-corner-all">
   <input type="hidden" value="<? echo $tgl; ?>" name="tgl" />
   <input type="hidden" value="<? echo $tanggal; ?>" name="tanggal" />
   <input type="hidden" value="<? echo $bulan; ?>" name="bulan" />
   <input type="hidden" value="<? echo $tahun; ?>" name="tahun" />
   <input type="hidden" value="<? echo $res['NIK']; ?>" name="nik" />
   <input type="hidden" value="<? echo $res['Nama']; ?>" name="nama" />
   <input type="hidden" value="<? echo $res['dept']; ?>" name="dept" />
   <input type="hidden" value="<? echo $res['jk']; ?>" name="jk" />
   <td><input type="submit" name="absen" value="Absen" onclick="return popitup('absen.php')"/></td>
   </form>