View difference between Paste ID: DHcxAFZQ and f0t43huq
SHOW: | | - or go back to the newest paste.
1
<?php
2
//........truncated code ..............
3
$gTotal = 0;
4
while($menu=mysql_fetch_array($pesanan))
5
{
6
$tot=$menu[harga]*$menu[jumlah];
7
echo "<tr>\n"
8
    ."<td>$menu[nama_menu]</td>\n"
9
    ."<td><div align='center'>$menu[jumlah]</td></div>\n"
10
    ."<td><div align='center'>$menu[harga]</td></div>\n"
11
    ."<td><div align='center'>$tot</td></div>";
12
$gTotal = $gTotal + $tot;
13
}
14
echo "</tr></table>";
15
    ."Total Pembelian Anda : Rp. $gTotal<br />\n"
16
    ."Bayar : Rp. <input name='bayar' type='text' id='bayar' />\n"
17
    ."<input name='proses' type='submit' id='proses' value='Click' />\n"
18
    ."<input name='kembali' type='text' id='kembali'/>\n"
19
    ."<input name='gTotal' type='hidden' id='gTotal' value='$gTotal' />\n" // add this line
20
    ."</form>";
21
?>
22
<script type="text/javascript">		
23-
		$('#proses').click(function(){
23+
      $('#proses').click(function(){
24-
      var  kembalian;
24+
          var  gTotal,bayar,kembalian;
25-
			{
25+
	  gTotal=parseFloat($('#gTotal').val().replace(/[^\d\.\-\ ]/g, ''));;
26-
			  gTotal=parseFloat($('#gTotal').val().replace(/[^\d\.\-\ ]/g, ''));;
26+
	  bayar=parseFloat($('#bayar').val().replace(/[^\d\.\-\ ]/g, ''));;
27-
			  bayar=parseFloat($('#bayar').val().replace(/[^\d\.\-\ ]/g, ''));;
27+
	  kembalian=gTotal-bayar;
28-
			  kembalian=gTotal-bayar;
28+
	  $('#kembali').val(kembalian);
29-
			  $('#kembali').val(kembalian);
29+
	});
30-
			}
30+