<tr>
<td>Tindakan</td>
<td>
<?
$sql = "SELECT kode_tarif, nama_tarif, harga FROM jenis_tarif";
$result = mysql_query($sql);
echo "<select name='kode_tarif'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['kode_tarif'] . "'>" . $row['nama_tarif'] ." - Rp.".$row['harga']. "</option>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td>Harga</td>
<td><input type="text" name="harga" id="harga"/></td>
</tr>
pada input harga ketika di klik nama tarif?? <tr>
<td>Tindakan</td>
<td>
<?php
include ('config.php'); // isinya adalah koneksi ke database
$result = mysql_query("select kode_tarif, nama_tarif, harga FROM jenis_tarif");
$jsArray = "var prdName = new Array();\n";
echo '<select name="kode_tarif" onchange="changeValue(this.value)">';
echo '<option>--Pilih --</option>';
while ($row = mysql_fetch_array($result)) {
echo '<option value="' . $row['kode_tarif'] . '">' . $row['kode_tarif'] . '</option>';
$jsArray .= "prdName['" . $row['kode_tarif'] . "'] = {harga:'" . addslashes($row['harga']) . "'};\n";
}
echo '</select>';
?>
</td>
</tr>
<script type="text/javascript">
<?php echo $jsArray; ?>
function changeValue(id){
document.getElementById('prd_harga').value = prdName[id].harga;
};
</script>
<tr>
<td><input type="text" name="harga" id="prd_harga" /></td>
</tr>