Mohon bantuannya mas? Bagaimana cara menghitung total bayar, vat , dan total order dari kode berikut ini: Mohon bantuannya sudah buntu ni (ini cuplikan kodenya)::)
</table>
				<br>
<table border="0" align="center">
				<div align="center" style="text-decoration:underline "><strong>Spesifikasi Project:</strong></div>
  <tr>
    <td width="500"><b>Material</b></td>
    <td width="20"><b>Qty</b></td>
    <td width="20"><b>Harga (Rp)</b></td>
    <td width="20"><b>Total (Rp)</b></td>
  </tr>
  <script>
function hitung() {
var jumlah01 = document.getElementsByName("jumlah01")[0].value;
var harga01 = document.getElementsByName("harga01")[0].value;
var total01 = parseInt(harga01) * parseInt(jumlah01);
document.getElementsByName("total01")[0].value = total01;
} 
function hitung02() {
var jumlah02 = document.getElementsByName("jumlah02")[0].value;
var harga02 = document.getElementsByName("harga02")[0].value;
var total02 = parseInt(harga02) * parseInt(jumlah02);
document.getElementsByName("total02")[0].value = total02;
} 
function hitung03() {
var jumlah03 = document.getElementsByName("jumlah03")[0].value;
var harga03 = document.getElementsByName("harga03")[0].value;
var total03 = parseInt(harga03) * parseInt(jumlah03);
document.getElementsByName("total03")[0].value = total03;
} 
function hitung04() {
var jumlah04 = document.getElementsByName("jumlah04")[0].value;
var harga04= document.getElementsByName("harga04")[0].value;
var total04 = parseInt(harga04) * parseInt(jumlah04);
document.getElementsByName("total04")[0].value = total04;
} 
function hitung05() {
var jumlah05 = document.getElementsByName("jumlah05")[0].value;
var harga05 = document.getElementsByName("harga05")[0].value;
var total05 = parseInt(harga05) * parseInt(jumlah05);
document.getElementsByName("total05")[0].value = total05;
} 
function hitung06() {
var jumlah06 = document.getElementsByName("jumlah06")[0].value;
var harga06 = document.getElementsByName("harga06")[0].value;
var total06 = parseInt(harga06) * parseInt(jumlah06);
document.getElementsByName("total06")[0].value = total06;
} 
function hitung07() {
var jumlah07 = document.getElementsByName("jumlah07")[0].value;
var harga07 = document.getElementsByName("harga07")[0].value;
var total07 = parseInt(harga07) * parseInt(jumlah07);
document.getElementsByName("total07")[0].value = total07;
} 
function hitung08() {
var jumlah08 = document.getElementsByName("jumlah08")[0].value;
var harga08 = document.getElementsByName("harga08")[0].value;
var total08 = parseInt(harga08) * parseInt(jumlah08);
document.getElementsByName("total08")[0].value = total08;
} 
function hitung09() {
var jumlah09 = document.getElementsByName("jumlah09")[0].value;
var harga09 = document.getElementsByName("harga09")[0].value;
var total09 = parseInt(harga09) * parseInt(jumlah09);
document.getElementsByName("total09")[0].value = total09;
} 
function hitung10() {
var jumlah10 = document.getElementsByName("jumlah10")[0].value;
var harga10 = document.getElementsByName("harga10")[0].value;
var total10 = parseInt(harga10) * parseInt(jumlah10);
document.getElementsByName("total10")[0].value = total10;
} 
function hitung11() {
var jumlah11 = document.getElementsByName("jumlah11")[0].value;
var harga11 = document.getElementsByName("harga11")[0].value;
var total11 = parseInt(harga11) * parseInt(jumlah11);
document.getElementsByName("total11")[0].value = total11;
} 
function hitung12() {
var jumlah12 = document.getElementsByName("jumlah12")[0].value;
var harga12 = document.getElementsByName("harga12")[0].value;
var total12 = parseInt(harga12) * parseInt(jumlah12);
document.getElementsByName("total12")[0].value = total12;
} 
function hitung13() {
var jumlah13 = document.getElementsByName("jumlah13")[0].value;
var harga13= document.getElementsByName("harga13")[0].value;
var total13 = parseInt(harga13) * parseInt(jumlah13);
document.getElementsByName("total13")[0].value = total13;
} 
function hitung14() {
var jumlah14 = document.getElementsByName("jumlah14")[0].value;
var harga14 = document.getElementsByName("harga14")[0].value;
var total14 = parseInt(harga14) * parseInt(jumlah14);
document.getElementsByName("total14")[0].value = total14;
} 
function hitung15() {
var jumlah15 = document.getElementsByName("jumlah15")[0].value;
var harga15 = document.getElementsByName("harga15")[0].value;
var total15 = parseInt(harga15) * parseInt(jumlah15);
document.getElementsByName("total15")[0].value = total15;
} 
</script>
  <tr>
    <td><input type=text name='material01' size='80'></td>
    <td><input type=text name='jumlah01' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga01' size='20' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='total01' size='20' value="0" readonly="total01" ></td>
  </tr>
  <tr>
    <td><input type=text name='material02' size='80'></td>
    <td><input type=text name='jumlah02' size='10' value="0" onKeyUp='hitung02()'></td>
    <td><input type=text name='harga02' size='20' value="0" onKeyUp='hitung02()'></td>
    <td><input type=text name='total02' size='20' value="0" readonly="total02"></td>
  </tr>
  <tr>
    <td><input type=text name='material03' size='80'></td>
    <td><input type=text name='jumlah03' size='10' value="0" onKeyUp='hitung03()'></td>
    <td><input type=text name='harga03' size='20' value="0" onKeyUp='hitung03()'></td>
    <td><input type=text name='total03' size='20' value="0" readonly="total03"></td>
  </tr>
  <tr>
    <td><input type=text name='material04' size='80'></td>
    <td><input type=text name='jumlah04' size='10' value="0" onKeyUp='hitung04()'></td>
    <td><input type=text name='harga04' size='20' value="0" onKeyUp='hitung04()'></td>
    <td><input type=text name='total04' size='20' value="0" readonly="total04"></td>
  </tr>
  <tr>
    <td><input type=text name='material05' size='80'></td>
    <td><input type=text name='jumlah05' size='10' value="0" onKeyUp='hitung05()'></td>
    <td><input type=text name='harga05' size='20' value="0" onKeyUp='hitung05()'></td>
    <td><input type=text name='total05' size='20' value="0" readonly="total05"></td>
  </tr>
  <tr>
    <td><input type=text name='material06' size='80'></td>
    <td><input type=text name='jumlah06' size='10' value="0" onKeyUp='hitung06()'></td>
    <td><input type=text name='harga06' size='20' value="0" onKeyUp='hitung06()'></td>
    <td><input type=text name='total06' size='20' value="0" readonly="total06"></td>
  </tr>
  <tr>
    <td><input type=text name='material07' size='80'></td>
    <td><input type=text name='jumlah07' size='10' value="0" onKeyUp='hitung07()'></td>
    <td><input type=text name='harga07' size='20' value="0" onKeyUp='hitung07()'></td>
    <td><input type=text name='total07' size='20' value="0" readonly="total07"></td>
  </tr>
  <tr>
    <td><input type=text name='material08' size='80'></td>
    <td><input type=text name='jumlah08' size='10' value="0" onKeyUp='hitung08()'></td>
    <td><input type=text name='harga08' size='20' value="0" onKeyUp='hitung08()'></td>
    <td><input type=text name='total08' size='20' value="0" readonly="total08"></td>
  </tr>
  <tr>
    <td><input type=text name='material09' size='80'></td>
    <td><input type=text name='jumlah09' size='10' value="0" onKeyUp='hitung09()'></td>
    <td><input type=text name='harga09' size='20' value="0" onKeyUp='hitung09()'></td>
    <td><input type=text name='total09' size='20' value="0" readonly="total09"></td>
  </tr>
  <tr>
    <td><input type=text name='material10' size='80'></td>
    <td><input type=text name='jumlah10' size='10' value="0" onKeyUp='hitung10()'></td>
    <td><input type=text name='harga10' size='20' value="0" onKeyUp='hitung10()'></td>
    <td><input type=text name='total10' size='20' value="0" readonly="total10"></td>
  </tr>
  <tr>
    <td><input type=text name='material11' size='80'></td>
    <td><input type=text name='jumlah11' size='10' value="0" onKeyUp='hitung11()'></td>
    <td><input type=text name='harga11' size='20' value="0" onKeyUp='hitung11()'></td>
    <td><input type=text name='total11' size='20' value="0" readonly="total11"></td>
  </tr>
  <tr>
    <td><input type=text name='material12' size='80'></td>
    <td><input type=text name='jumlah12' size='10' value="0" onKeyUp='hitung12()'></td>
    <td><input type=text name='harga12' size='20' value="0" onKeyUp='hitung12()'></td>
    <td><input type=text name='total12' size='20' value="0" readonly="total12"></td>
  </tr>
  <tr>
    <td><input type=text name='material13' size='80'></td>
    <td><input type=text name='jumlah13' size='10' value="0" onKeyUp='hitung13()'></td>
    <td><input type=text name='harga13' size='20' value="0" onKeyUp='hitung13()'></td>
    <td><input type=text name='total13' size='20' value="0" readonly="total13"></td>
  </tr>
  <tr>
    <td><input type=text name='material14' size='80'></td>
    <td><input type=text name='jumlah14' size='10' value="0" onKeyUp='hitung14()'></td>
    <td><input type=text name='harga14' size='20' value="0" onKeyUp='hitung14()'></td>
    <td><input type=text name='total14' size='20' value="0" readonly="total14"></td>
  </tr>
  <tr>
    <td><input type=text name='material15' size='80'></td>
    <td><input type=text name='jumlah15' size='10' value="0" onKeyUp='hitung15()'></td>
    <td><input type=text name='harga15' size='20' value="0" onKeyUp='hitung15()'></td>
    <td><input type=text name='total15' size='20' value="0" readonly="total15"></td>
  </tr>
 
</table>
				
<br>
<?php
$sql="select * from project";
$tot1=$_POST['total01'];
$tot2=$_POST['total02'];
$grand= $tot1 + $tot2;
$totalorder = $grand;
?>
				 <table border='0' align='right'>
				  <tr><td>TOTAL Order (Rp)</td> <td>   <input type=text name='total_order' size='25'  value='<?php echo $totalorder; ?>' readonly="total_order"></td></tr>
				   <tr><td>Vat 10% (Rp)</td> <td>   <input type=text name='vat' size='25'  value="0" readonly="vat"></td></tr>
				   <tr><td><b>TOTAL BAYAR (Rp)</b></td> <td>   <input type=text name='total_bayar' size='25'  value="0" readonly="total_bayar"></td></tr>
				   <tr> <td></td> <td align="right"> <input type="reset" value="Batal"/> &nbsp;<input type="submit" value="Simpan"/></td></tr>
				   </table>
				   <table border='0' align='left'>
				   <b>Staff yang bertugas:</b><br><br>
				    <tr><td>Nama Staff </td> <td>   <input type=text name='staff' size='25'  value="<?php echo '' . $_SESSION['ID'] . '';?>" readonly="staff"></td></tr>
				   <tr><td width='100'> Hari / Tanggal </td> <td width='150'>   <input type=text name='tanggal' size='25' value="<?php echo date('D, j-F-Y ');  ?>" readonly="tanggal"></td></tr>
				  <tr><td width='100'> Jam</td> <td width='150'>   <input type=text name='jam' size='25' value="<?php include('jam.php'); ?>" readonly="jam"></td></tr>
				 
                
	 </table>
Silahkan login untuk menjawab!
1
Loading...
Ellyx Christian · Apr 24, 2012 · 1 Suka · 0 Tidak Suka
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"xml:lang="en"lang="en">

<head>
<title>Form Pembayaran Makanan</title>
<script type="text/javascript" src="currencyFields.js"></script>
<script language="JavaScript" type="text/JavaScript">

<!--
function hitung() {
var myForm = document.form1;
var to1 = parseInt(myForm.jumlah01.value) * parseInt(myForm.harga01.value);
var to2 = parseInt(myForm.jumlah02.value) * parseInt(myForm.harga02.value);
var to3 = parseInt(myForm.jumlah03.value) * parseInt(myForm.harga03.value);
var to4 = parseInt(myForm.jumlah04.value) * parseInt(myForm.harga04.value);
var to5 = parseInt(myForm.jumlah05.value) * parseInt(myForm.harga05.value);
var to6 = parseInt(myForm.jumlah06.value) * parseInt(myForm.harga06.value);
var to7 = parseInt(myForm.jumlah07.value) * parseInt(myForm.harga07.value);
var to8 = parseInt(myForm.jumlah08.value) * parseInt(myForm.harga08.value);
var to9 = parseInt(myForm.jumlah09.value) * parseInt(myForm.harga09.value);
var to10 = parseInt(myForm.jumlah10.value) * parseInt(myForm.harga10.value);
var to11 = parseInt(myForm.jumlah11.value) * parseInt(myForm.harga11.value);
var to12 = parseInt(myForm.jumlah12.value) * parseInt(myForm.harga12.value);
var to13 = parseInt(myForm.jumlah13.value) * parseInt(myForm.harga13.value);
var to14 = parseInt(myForm.jumlah14.value) * parseInt(myForm.harga14.value);
var to15 = parseInt(myForm.jumlah15.value) * parseInt(myForm.harga15.value);

var totalOrder= to1 + to2 + to3 + to4 + to5 + to6 + to7 + to8 + to9 + to10 + to11 + to12 + to13 + to14 + to15;
console.log(myForm.jumlah04.value);
myForm.total_order.value = totalOrder;
myForm.vat.value = ((10/100)*totalOrder);
myForm.total_bayar.value = totalOrder - parseInt(myForm.vat.value);

}

function hapus(){
document.form1.reset();
}

//-->

</script>
</head>

<body background="cup.jpg">
<h2 align="center">Form Pemesanan Makanan Berbasis JavaScript</h2>
<form name = "form1" action="#">
<table border="0" align="center">

<tr>
    <td width="500"><b>Material</b></td>
    <td width="20"><b>Qty</b></td>
    <td width="20"><b>Harga (Rp)</b></td>
    <td width="20"><b>Total (Rp)</b></td>
  </tr>
<tr>
    <td><input type=text name='material01' size='80'></td>
    <td><input type=text name='jumlah01' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga01' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total01' size='20' value="0" readonly="total01" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material02' size='80'></td>
    <td><input type=text name='jumlah02' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga02' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total02' size='20' value="0" readonly="total02" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
<tr>
    <td><input type=text name='material03' size='80'></td>
    <td><input type=text name='jumlah03' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga03' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total03' size='20' value="0" readonly="total03" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material04' size='80'></td>
    <td><input type=text name='jumlah04' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga04' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total04' size='20' value="0" readonly="total04" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material05' size='80'></td>
    <td><input type=text name='jumlah05' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga05' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total05' size='20' value="0" readonly="total05" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material06' size='80'></td>
    <td><input type=text name='jumlah06' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga06' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total06' size='20' value="0" readonly="total06" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material07' size='80'></td>
    <td><input type=text name='jumlah07' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga07' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total07' size='20' value="0" readonly="total07" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material08' size='80'></td>
    <td><input type=text name='jumlah08' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga08' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total08' size='20' value="0" readonly="total08" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material09' size='80'></td>
    <td><input type=text name='jumlah09' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga09' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total09' size='20' value="0" readonly="total09" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material10' size='80'></td>
    <td><input type=text name='jumlah10' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga10' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total10' size='20' value="0" readonly="total10" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material11' size='80'></td>
    <td><input type=text name='jumlah11' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga11' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total11' size='20' value="0" readonly="total11" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material12' size='80'></td>
    <td><input type=text name='jumlah12' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga12' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total12' size='20' value="0" readonly="total12" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material13' size='80'></td>
    <td><input type=text name='jumlah13' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga13' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total13' size='20' value="0" readonly="total13" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material14' size='80'></td>
    <td><input type=text name='jumlah14' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga14' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total14' size='20' value="0" readonly="total14" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
  <tr>
    <td><input type=text name='material154' size='80'></td>
    <td><input type=text name='jumlah15' size='10' value="0" onKeyUp='hitung()'></td>
    <td><input type=text name='harga15' size='20' value="0" onKeyUp='hitung()' style="text-align:right"></td>
    <td><input type=text name='total15' size='20' value="0" readonly="total15" onkeyup="hitung()" style="text-align:right"></td>
  </tr>
<tr>
<td colspan="3" align="right" bgcolor="white"><strong>Total Order (Rp)</strong></td>
<td><input type="text" name="total_order" style="text-align:right" readonly="total_order" value="0"/></td>
</tr>

<tr>
<td colspan="3" align="right" bgcolor="white"><strong>Vat 10% (Rp)</strong></td>
<td><input type="text" name="vat" style="text-align:right" readonly="vat" value="0"/></td>
</tr>

<tr>
<td colspan="3" align="right" bgcolor="white"><strong>Total Bayar (Rp)</strong></td>
<td><input type="text" name="total_bayar" style="text-align:right" onchange="currency(this);" readonly="total_bayar" value="0"/></td>
</tr>
<tr>
 <tr> <td></td> <td align="right"> </td></tr>
<td colspan="4" align="right" bgcolor="white"><input type="reset" value="Batal"/> &nbsp;<input type="submit" value="Simpan"/></td>
</tr>

</table>
</form>
</body>
</html>
0
Loading...
ant · Apr 24, 2012 · 0 Suka · 0 Tidak Suka
Terimakasih banyak mas Ellyx? Problem Solved !!!!!!!!:):):)