Full Face
Senin, 28 Februari 2011
Tugas praktikum modul5
<br /> function totalHarga(){<br /> var harga;<br /> var pesanan;<br /> var total = 0;<br /> for(i = 0; i < 12; i += 2){ harga = parseInt(document.pemesanan[i].value); pesanan = parseInt(document.pemesanan[i + 1].value); if(pesanan > 0){<br /> total = total + (harga * pesanan);<br /> }<br /> document.pemesanan.total.value = total;<br /> }<br /> }<br /> <br /> function diskon(){<br /> var total = parseInt(document.pemesanan.total.value);<br /> var diskon = 0;<br /> if(total >= 100000){<br /> diskon = 7.5 / 100 * total;<br /> }<br /> else if(total >= 50000){<br /> diskon = 5 / 100 * total;<br /> }<br /> else if(total >= 25000){<br /> diskon = 2.5 / 100 * total;<br /> }<br /> document.pemesanan.diskon.value = diskon;<br /> }<br /> <br /> function jumlahBayar(){<br /> var total = parseInt(document.pemesanan.total.value);<br /> var diskon = parseInt(document.pemesanan.diskon.value);<br /> var bayar = total - diskon;<br /> document.pemesanan.bayar.value = bayar;<br /> }<br /> <br /> function proses(){<br /> totalHarga();<br /> diskon();<br /> jumlahBayar();<br /> }<br /> <br /> function reset(){<br /> var elemen = document.pemesanan;<br /> elemen.pesan1.value = "";<br /> elemen.pesan2.value = "";<br /> elemen.pesan3.value = "";<br /> elemen.pesan4.value = "";<br /> elemen.pesan5.value = "";<br /> elemen.pesan6.value = "";<br /> elemen.total.value = "";<br /> elemen.diskon.value = "";<br /> elemen.bayar.value = "";<br /> }<br />
<br /> <!DOCTYPEhtml><br /> <html lang="en"><br /> <head><br /> <title>Form Pemesanan</title><br /> <script language="JavaScript" type="text/javascript" src="pemesanan.js"></script><br /> <br /> </head><br /> <body><br /> <br /> <h2><font face="Comic Sans MS" color="purple">.::Form Pemesanan Berbasis Java Script::.</font></h2><br /> <form name="pemesanan" action="#"><table border="3"><tr bgcolor=#eed0ea> <th>No</th> <th>Makanan / Minuman</th> <th>Harga</th> <th>Pesan</th> </tr> <tr> <td align="center">1</td> <td>Bakso Super</td> <td>@<input type="text" name="harga1" value="12000" onchange="proses()" /></td> <td><input type="text" name="pesan1" onchange="proses()" /></td> </tr> <tr> <td align="center">2</td> <td>Soto Madura</td> <td>@<input type="text" name="harga2" value="10000" onchange="proses()" /></td> <td><input type="text" name="pesan2" onchange="proses()" /></td> </tr> <tr> <td align="center">3</td> <td>Mie Ayam Istimewa</td> <td>@<input type="text" name="harga3" value="15000" onchange="proses()" /></td> <td><input type="text" name="pesan3" onchange="proses()" /></td> </tr> <tr> <td align="center">4</td> <td>Es Degan Cihuy</td> <td>@<input type="text" name="harga4" value="5000" onchange="proses()" /></td> <td><input type="text" name="pesan4" onchange="proses()" /></td> </tr> <tr> <td align="center">5</td> <td>Es Campur Merapi</td> <td>@<input type="text" name="harga5" value="7000" onchange="proses()" /></td> <td><input type="text" name="pesan5" onchange="proses()" /></td> </tr> <tr> <td align="center">6</td> <td>Gorengan Campur</td> <td>@<input type="text" name="harga6" value="500" onchange="proses()" /></td> <td><input type="text" name="pesan6" onchange="proses()" /></td> </tr> <tr> <td colspan="3" align="right" bgcolor=#eed0ea>Jumlah Total</td> <td><input type="text" name="total" readonly /></td> </tr> <tr> <td colspan="3" align="right" bgcolor=#eed0ea>Diskon</td> <td><input type="text" name="diskon" readonly /></td> </tr> <tr> <td colspan="3" align="right" bgcolor=#eed0ea>Jumlah Dibayar</td> <td><input type="text" name="bayar" readonly /></td> </tr> </table><br><br /> <input type="button" name="batal" value="Batal" onclick="reset()" /><br /> </form></body><br /> </html><br />
Tidak ada komentar:
Posting Komentar
Posting Lebih Baru
Posting Lama
Beranda
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar