masih tetep gag bisa mas.
kode nama barangnya itu yang gag muncul di combo box-nya.
ini kode keseluruhan file dtlrc.php saya mas
<?php
require_once("libs/controller/Keluar.php");
$request = new Keluar();
$action = $_REQUEST['action'];
switch($action){
case 'addNo':
{
$no_trjual = $_REQUEST['no'];
$tanggal = $_REQUEST['tanggal'];
$status = $_REQUEST['status'];
$result = $request->addKeluar($no_trjual,$tanggal,$status);
if($result === TRUE){
echo "<font color='red'>(Insert berhasil)</font>";
} else {
echo $result;
}
} break;
case 'delete':
{
$id = $_REQUEST['id'];
$kd_barang = $_REQUEST['kd_barang'];
$result = $request->deleteBarang($id,$kd_barang);
if($result === TRUE){
echo "<font color='red'>(Delete Berhasil)</font>";
} else {
echo $result;
}
} break;
case 'addDtl':
{
$no_trjual = $_REQUEST['no'];
$kd_barang = $_REQUEST['prdId'];
$harga = $_REQUEST['harga'];
$jml = $_REQUEST['jml'];
$result = $request->addBarang($no_trjual,$kd_barang,$harga,$jml);
if($result === TRUE){
echo "<font color='red'>(Insert berhasil)</font>";
$_REQUEST['jml'] = "";
} else {
echo $result;
}
}
case 'add':
{
$no = $_REQUEST['no'];
$result = $request->addStock($no);
if($result === FALSE){
echo " (<font color='red'> Barang Tidak Tersedia </font>)";
}else{
echo " ";
}
} break;
default:
}
?>
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style2 {color: #009933}
-->
</style>
<div id="main1">
<form method="POST" name="Form Request" action="index.php?page=dtlrc&action=addDtl"><br />
<label>No Penjualan</label>
<input class="text" type="text" size="20" readonly="true" value="<?php echo $_REQUEST['no']; ?>" name="no"/><br />
<label>Nama Barang</label>
<?php
$saya = mysql_query("select * from barang");
$jsArray = "var prdName = new Array();\n";
echo '<select name="prdId" onchange="document.getElementById(\'harga\').value = prdName[this.value]">';
echo '<option>-------</option>';
while ($row = mysql_fetch_array($saya)) {
echo '<option value="' . $row['id_barang'] . '">' . $row['namabarang'] . '</option>';
$jsArray .= "prdName['" . $row['id_barang'] . "'] = '" . addslashes($row['hargajual']) . "';\n";
}
echo '</select>';
?>
Harga: <input type="text" name="harga" id="harga"/>
<script type="text/javascript">
<?php echo $jsArray; ?>
</script>
<label>Harga (Rp)</label>
<input class="text" type="text" name="harga" readonly="true" value="<?php echo $_REQUEST['harga']; ?>" />
<br /><label>Jumlah</label>
<input class="text" type="text" size="30" name="jml" value="<?php echo $_REQUEST['jml']; ?>" /><br>
<br />
<input class="button" type="submit" name="tambah" value="Tambah" /><a href="?page=rc"><input class="button" type="button" name="save" value="Save" />
</a>
</br>
</form>
</div><div id="main1">
<table border="0">
<tr>
<th width="75">Nama</th>
<th width="50">Jumlah</th>
<th width="50">Harga</th>
<th width="50">Subtotal</th>
<th width="50">Delete</th>
</tr>
<?php
$no = $_REQUEST['no'];
$id = $request->getId($no);
$result = $request->showDtl($id);
while($row = $result->fetch_assoc()){
$sub=$row[jml]*$row[harga];
echo "<tr>";
echo "<td>$row[namabarang]</td>";
echo "<td>$row[jml]</td>";
echo "<td>Rp.$row[harga]</td>";
echo "<td align='right'>Rp.$sub</td>";
echo "<td class='act'><a href='index.php?page=dtlrc&action=delete&id=$row[id_trjual]&kd_barang=$row[kd_barang]&no=$row[no_trjual]&tanggal=$row[tanggal]'><img border='0' src='images/hapus.png'></a></td>";
echo "</tr>";
$total=$total+$sub;
}
echo "<tr><td align='right' colspan='4'>Total : Rp.$total</td></tr>";
?>
</table>
</div>