saya membuat form dengan combobox dinamis, masalah nya yaitu dalam 1 form terdapat 2 combobox yang masing-masing dari tabel yang berbeda...chekit-out...!yang bagian atas tidak berjalan semestinya
tabel kendaraan(nounit,model,noserie,smr)
tabel sparepart(partnumber,partname,ic1,ic2,ic3)
<html>
<head></head>
<body>
<form method="POST" action="">
	<table>
		<tr>
			<td >No.Spk</td>
			<td><input  type="text" name="no_spk" ></td>
		</tr>
		<tr>
			<td>Lokasi Storing</td>
			<td><input type="password" name="lokasi"></td>
		</tr>
		<tr>
			<td>TANGGAL Spk</td>
			<td><input font="13px" type="date" name="tgl_spk"></td>
		</tr>
		<tr>
			<td>No.Unit</td>
						<td><?php  
				include 'connection.php'; 
			    $connection1 =mysql_connect ($server,$user,$pass);
				$db1 = mysql_select_db($db);
				$result1 = mysql_query("select * from kendaraan");  
				$jsArray1 = "var a = new Array();";  
				echo '<select name="nounit" onchange="changeValue(this.value)">';  
				echo '<option>-------</option>';  
				while ($row1 = mysql_fetch_array($result1)) {  
				echo '<option value="' . $row1['nounit'] . '">' . $row1['nounit'] . '</option>';  
				$jsArray1 .= "a['" . $row1['nounit'] . "'] = {
							smr:'" . addslashes($row1['smr']) . "',
							model:'" . addslashes($row1['model']) . "',
							noserie:'".addslashes($row1['noserie'])."'};";  }  
				echo '</select>';  
				?>    
			</td>
		</tr>
		<tr>
			<td>SMR</td>
			<td><input type="text" name="smr" id="z_smr" readonly="true"/></td>
		</tr>
		<tr>
			<td>Model</td>
			<td><input type="text"  name="model" id="z_model" readonly="true"/></td>
		</tr>
		<tr>
			<td>No Serie</td>
			<td><input type="text"  name="noserie" id="z_noserie" readonly="true"/></td>
		</tr>
			<script type="text/javascript">  
			<?php echo $jsArray1; ?>
			function changeValue(id){
			document.getElementById('z_smr').value = a[id].smr;
			document.getElementById('z_model').value = a[id].model;
			document.getElementById('z_noserie').value = a[id].noserie;
			};
			</script>
		<tr>
			<td>Jenis Part/Material</td>
			<td><select name="jmaterial">
				<option >pilih</option>
				<option name="Suku Cadang/Parts">Suku Cadang/Parts</option>
				<option name="Bahan Habis Pakai">Bahan Habis Pakai</option>
				<option name="Consumable Goods">Consumable Goods</option>
				<option name="Pelumas/Oil &Grease">Pelumas/Oil &Grease </option>
				<option name="Ban /tyre">Ban /tyre</option>
				<option name="Bahan Lain/Others">Bahan Lain/Others</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>Pesanan Untuk</td>
			<td><select name="pu">
				<option >pilih</option>
				<option name="Repair(B/D)">Repair(B/D)</option>
				<option name="Overhaul(O/H)">Overhaul(O/H)</option>
				<option name="Maintenance">Maintenance</option>
				<option name="Others">Others</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>Kelompok Komponen</td>
			<td><select name="kk">
				<option >pilih</option>
				<option name="Engine&Accssories">Engine&Accssories</option>
				<option name="Undercarriage/Tyre">Undercarriage/Tyre</option>
				<option name="Pneumatic System">Pneumatic System</option>
				<option name="T/M & Torque Converter">T/M & Torque Converter</option>
				<option name="Hydraulic System">Hydraulic System</option>
				<option name="General(Attachment,Chasis&Others)">General(Attachment,Chasis&Others)</option>
				<option name="Differentional&Final Drive">Differentional&Final Drive</option>
				<option name="Electrial System">Electrial System</option>
				</select>
			</td>
		</tr>
	</table >

	<table border="1" cellpadding="5" cellspacing="0">
	<p>&nbsp;</p>
	<tr>
		<td>S/N Catalog</td>
		<td>FIGN No.</td>
		<td>Index No.</td>
		<td>Part Number</td>
		<td>Interchange</td>
		<td>Interchange</td>
		<td>Interchange</td>
		<td>Uraian/Deskription</td>
		<td>Jumlah</td>
		<td>Keterangan</td>
	</tr>
	<tr>
		<td><input type="text" name="sncatalog" size="5"></td>
		<td><input type="text" name="fignno" size="5"></td>
		<td><input type="text" name="indexno" size="5"></td>
		<td><?php  
				include 'connection.php'; 
				$connection =mysql_connect ($server,$user,$pass);
				$db = mysql_select_db($db);
				$result = mysql_query("select * from sparepart");  
				$jsArray = "var prdName = new Array();\n";  
				echo '<select name="partnumber" onchange="changeValue(this.value)">';  
				echo '<option>-------</option>';  
				while ($row = mysql_fetch_array($result)) {  
				echo '<option value="' . $row['partnumber'] . '">' . $row['partnumber'] . '</option>';  
				$jsArray .= "prdName['" . $row['partnumber'] . "'] = {
							ic1:'" . addslashes($row['ic1']) . "',
							ic2:'" . addslashes($row['ic2']) . "',
							ic3:'" . addslashes($row['ic3']) . "',
							partname:'".addslashes($row['partname'])."'};";  }  
				echo '</select>';  
				?> </select></td>
		<td><input type="text" name="ic1" id="prd_ic1" readonly="true"/></td>
		<td><input type="text" name="ic2" id="prd_ic2" readonly="true"/></td>
		<td><input type="text" name="ic3" id="prd_ic3" readonly="true"/></td>
		<td><input type="text" name="partname" id="prd_partname" readonly="true"/></td>
			<script type="text/javascript">  
			<?php echo $jsArray; ?>
			function changeValue(id){
			document.getElementById('prd_ic1').value = prdName[id].ic1;
			document.getElementById('prd_ic2').value = prdName[id].ic2;
			document.getElementById('prd_ic3').value = prdName[id].ic3;
			document.getElementById('prd_partname').value = prdName[id].partname;
			};
			</script>
		<td><input type="text" name="jumlah" size="5"></td>
		<td><textarea rows="3" cols="15" name="keterangan"></textarea></td>
	</tr>

  

	</table>
</form>
  <input type="reset" name="reset" value="RESET"/>
  <input type="submit" name="save" value="SAVE"/>
</body>
</html>
Silahkan login untuk menjawab!