Advertisement
cdsatrian

non jquery

Jun 12th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  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' onSubmit='hitung_kembalian();return true;' />\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. function hitung_kembalian(){
  24.   gTotal=document.getElementById('gTotal').value;
  25.   bayar=document.getElementById('bayar').value;
  26.   kembalian=gTotal-bayar;
  27.   document.getElementById('bayar').value=kembalian
  28. }
  29. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement