boleh minta bantu bagaimana cara menampilkan harga pada textbox ketika combobox di klik ? saya menggunakan dreamweaver cs6 mohon bantuannya :)

[code=php]
<table width="372" border="0" align="left">
<tr>
<th scope="row" align="left">Kode Sewa</th>
<td>:</td>
<td align="left">
<input type="text" name="kode" id="kode" /></td>
</tr>
<tr align="left">
<th width="108" scope="row">&nbsp;</th>
<td width="7">&nbsp;</td>
<td width="216" align="left"><p>
Untuk mendapatkan kode sewa silahkan klik<a href="cap/cap.php"> Disini !</a></p></td>
</tr>

<tr>
<th scope="row" align="left">Nama Penyewa</th>
<td>:</td>
<td align="left">
<input type="text" name="penyewa" id="penyewa" /></td>
</tr>
<tr>
<th scope="row" align="left">Nama Team</th>
<td>:</td>
<td align="left">
<input type="text" name="team" id="team" /></td>
</tr>
<tr>
<th scope="row" align="left">No. Telp</th>
<td>:</td>
<td align="left">
<input type="text" name="telp" id="telp" /></td>
</tr>
<tr>
<th scope="row" align="left">Lapangan</th>
<td>:</td>
<td align="left"><label for="select"></label>
<select name="lapangan" id="lapangan">
<option selected="selected">-Pilih-</option>
<option>Lapangan 1</option>
<option>Lapangan 2</option>
</select></td>
</tr>
<tr>
<th scope="row" align="left">Hari</th>
<td>:</td>
<td align="left"><input type="text" name="hari" class="tcal" value="<?php echo $dataTanggal; ?>"/></td>
</tr>
<tr>
<th scope="row" align="left">Waktu</th>
<td>:</td>
<td align="left"><select name="jam" id="jam">
<option selected="selected">-Pilih-</option>
<option>07.00 - 08.00</option>
<option>08.00 - 09.00</option>
<option>09.00 - 10.00</option>
<option>10.00 - 11.00</option>
<option>11.00 - 12.00</option>
<option>12.00 -13.00</option>
<option>13.00 - 14.00</option>
<option>14.00 - 15.00</option>
<option>15.00 - 16.00</option>
<option>16.00 - 17.00</option>
<option>17.00 - 18.00</option>
<option>18.00 - 19.00</option>
<option>19.00 - 20.00</option>
<option>20.00 - 21.00</option>
<option>21.00 - 22.00</option>
<option>22.00 - 23.00</option>
<option>23.00 - 24.00</option>
</select>
<select name="waktu" id="waktu">
<option selected="selected">-Pilih-</option>
<option>Pagi</option>
<option>Malam</option>
</select></td>
</tr>
<tr>
<th scope="row" align="left">Harga</th>
<td>:</td>
<td align="left"><input type="text" name="harga" id="harga" /></td>
</tr>
<tr>
<th colspan="3" scope="row"><input type="submit" name="button" id="button" value="Pesan" />
<input type="reset" name="button2" id="button2" value="Batal" /></th>
</tr>
</table>
Silahkan login untuk menjawab!
0
Loading...
aaron49 · Jan 1, 2016 · 0 Suka · 0 Tidak Suka
mungkin bisa membantu teh ini ada script yang sama dengan kasusnya teteh, semoga bermanfaat

<?php
mysql_connect("localhost", "root", "");
mysql_select_db("klinik");
$result = mysql_query("select * from tbl_pemeriksaan");  
$jsArray = "var prdName = new Array();\n";  

echo '<center>Noreg:<select name="prdId" onchange="changeValue(this.value)">';     
            
            echo '<option>-------</option>';  
while ($row = mysql_fetch_array($result)) {  
    echo '<option value="' . $row['no_pemeriksaan'] . '">' . $row['no_pemeriksaan'] . '</option>';  
    $jsArray .= "prdName['" . $row['no_pemeriksaan'] . "'] = {name:'" . addslashes($row['tgl_pemeriksaan']) . "',anam:'".addslashes($row['anamnesa'])."',dial:'".addslashes($row['diagnosa'])."',peny:'".addslashes($row['nama_penyakit'])."'};\n";  
}  
echo '</select>';  


?>
<br>
<br>
Tgl Periksa:     <input type="text" name="prod_name" id="prd_name"readonly/>  
<br>
<br>
Anamnesa:        <input type="text" name="prod_anam" id="prd_anam"readonly/>  
<br>
<br>
Diagnosa:        <input type="text" name="prod_dial" id="prd_dial"readonly/>  
<br>
<br>
Penyakit:        <input type="text" name="prod_peny" id="prd_peny"readonly/>  

<script type="text/javascript">  
<?php echo $jsArray; ?>  
function changeValue(id){  
document.getElementById('prd_name').value = prdName[id].name;  
document.getElementById('prd_anam').value = prdName[id].anam;  
document.getElementById('prd_dial').value = prdName[id].dial;  
document.getElementById('prd_peny').value = prdName[id].peny;  
};    
</script>