Tugas Praktikum Modul 5 (Java Script)
On Selasa, 01 Maret 2011
0
komentar
Gambar Hasil Praktikum
Source Code:
<!Doctype html>
<html lang="en">
<html>
<head>
<title>WARUNG BAKAR-BAKAR "Uenak"</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
function hitung(){
var myForm = document.form1;
var bakar1 = 17000 * eval(myForm.inp1.value);
var bakar2 = 10000 * eval(myForm.inp2.value);
var bakar3 = 25000 * eval(myForm.inp3.value);
var minum1 = 7000 * eval(myForm.inp4.value);
var minum2 = 7000 * eval(myForm.inp5.value);
var total = bakar1 + bakar2 + bakar3 + minum1 + minum2;
if (total > 50000 && total <= 100000){
myForm.Total.value = total;
myForm.Diskon.value = 10000;
myForm.Bayar.value = total - 10000;
}
else if (total > 100000 && total <= 200000) {
myForm.Total.value = total;
myForm.Diskon.value = 15000;
myForm.Bayar.value = total - 15000;
}
else if (total > 200000) {
myForm.Total.value = total;
myForm.Diskon.value = 20000;
myForm.Bayar.value = total - 20000;
}
else {
myForm.Total.value = total;
myForm.Diskon.value = 0;
myForm.Bayar.value = total - 0;
}
myForm.bayar1.value=bakar1;
myForm.bayar2.value=bakar2;
myForm.bayar3.value=bakar3;
myForm.bayar4.value=minum1;
myForm.bayar5.value=minum2;
}
//-->
</script>
<h3 align="center">WARUNG BAKAR-BAKAR "Uenak"</h3>
<form name="form1" action="#">
<div align="center">
<table border="5">
<tr>
<th bgcolor="#0000CC">No</th>
<th bgcolor="#0000CC">Makanan/Minuman</th>
<th bgcolor="#0000CC">Harga</th>
<th bgcolor="#0000CC">Pesan</th>
<th bgcolor="#0000CC">Total</th>
</tr>
<tr>
<td width="15" bgcolor="#0099FF">1</td>
<td width="200" bgcolor="#0099FF">Gurami Bakar</td>
<td width="150" bgcolor="#0099FF">@<input type="text" name="bakar1" value="17000" size="15" disabled="true"/></td>
<td width="150" bgcolor="#0099FF"><input type="text" name="inp1" value="0" onChange="hitung()"/></td>
<td width="150"><input type="text" name="bayar1" disabled="true"/></td>
</tr>
<tr>
<td bgcolor="#0099FF">2</td>
<td bgcolor="#0099FF">Ayam Bakar</td>
<td bgcolor="#0099FF">@<input type="text" name="bakar2" value="10000" size="15" disabled="true"/></td>
<td bgcolor="#0099FF"><input type="text" name="inp2" value="0" onChange="hitung()"/></td>
<td><input type="text" name="bayar2" disabled="true"/></td>
</tr>
<tr>
<td bgcolor="#0099FF">3</td>
<td bgcolor="#0099FF">Ikan Laut Bakar</td>
<td bgcolor="#0099FF">@<input type="text" name="bakar3" value="25000" size="15" disabled="true"/></td>
<td bgcolor="#0099FF"><input type="text" name="inp3" value="0" onChange="hitung()"/></td>
<td><input type="text" name="bayar3" disabled="true"/></td>
</tr>
<tr>
<td bgcolor="#0099FF">4</td>
<td bgcolor="#0099FF">Es Rumput Laut</td>
<td bgcolor="#0099FF">@<input type="text" name="minum1" value="7000" size="15" disabled="true"/></td>
<td bgcolor="#0099FF"><input type="text" name="inp4" value="0" onChange="hitung()"/></td>
<td><input type="text" name="bayar4" disabled="true"/></td>
</tr>
<tr>
<td bgcolor="#0099FF">5</td>
<td bgcolor="#0099FF">Es Degan</td>
<td bgcolor="#0099FF">@<input type="text" name="minum2" value="7000" size="15" disabled="true"/></td>
<td bgcolor="#0099FF"><input type="text" name="inp5" value="0" onChange="hitung()"/></td>
<td><input type="text" name="bayar5" disabled="true"/></td>
</tr>
<tr>
<td colspan="4" align="right" bgcolor="#FF0000">Jumlah Total</td>
<td><input type="text" name="Total" disabled="true" /></td>
</tr>
<tr>
<td colspan="4" align="right" bgcolor="#FFFFFF">Diskon</td>
<td><input type="text" name="Diskon" disabled="true" /></td>
</tr>
<tr>
<td colspan="4" align="right" bgcolor="#FFFF00">Jumlah Dibayar</td>
<td><input type="text" name="Bayar" disabled="true" align="right"/></td>
</tr>
</table>
<br/>
<input type="reset" value="Batal" />
</div>
</form>
</body>
</html>
<html lang="en">
<html>
<head>
<title>WARUNG BAKAR-BAKAR "Uenak"</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
function hitung(){
var myForm = document.form1;
var bakar1 = 17000 * eval(myForm.inp1.value);
var bakar2 = 10000 * eval(myForm.inp2.value);
var bakar3 = 25000 * eval(myForm.inp3.value);
var minum1 = 7000 * eval(myForm.inp4.value);
var minum2 = 7000 * eval(myForm.inp5.value);
var total = bakar1 + bakar2 + bakar3 + minum1 + minum2;
if (total > 50000 && total <= 100000){
myForm.Total.value = total;
myForm.Diskon.value = 10000;
myForm.Bayar.value = total - 10000;
}
else if (total > 100000 && total <= 200000) {
myForm.Total.value = total;
myForm.Diskon.value = 15000;
myForm.Bayar.value = total - 15000;
}
else if (total > 200000) {
myForm.Total.value = total;
myForm.Diskon.value = 20000;
myForm.Bayar.value = total - 20000;
}
else {
myForm.Total.value = total;
myForm.Diskon.value = 0;
myForm.Bayar.value = total - 0;
}
myForm.bayar1.value=bakar1;
myForm.bayar2.value=bakar2;
myForm.bayar3.value=bakar3;
myForm.bayar4.value=minum1;
myForm.bayar5.value=minum2;
}
//-->
</script>
<h3 align="center">WARUNG BAKAR-BAKAR "Uenak"</h3>
<form name="form1" action="#">
<div align="center">
<table border="5">
<tr>
<th bgcolor="#0000CC">No</th>
<th bgcolor="#0000CC">Makanan/Minuman</th>
<th bgcolor="#0000CC">Harga</th>
<th bgcolor="#0000CC">Pesan</th>
<th bgcolor="#0000CC">Total</th>
</tr>
<tr>
<td width="15" bgcolor="#0099FF">1</td>
<td width="200" bgcolor="#0099FF">Gurami Bakar</td>
<td width="150" bgcolor="#0099FF">@<input type="text" name="bakar1" value="17000" size="15" disabled="true"/></td>
<td width="150" bgcolor="#0099FF"><input type="text" name="inp1" value="0" onChange="hitung()"/></td>
<td width="150"><input type="text" name="bayar1" disabled="true"/></td>
</tr>
<tr>
<td bgcolor="#0099FF">2</td>
<td bgcolor="#0099FF">Ayam Bakar</td>
<td bgcolor="#0099FF">@<input type="text" name="bakar2" value="10000" size="15" disabled="true"/></td>
<td bgcolor="#0099FF"><input type="text" name="inp2" value="0" onChange="hitung()"/></td>
<td><input type="text" name="bayar2" disabled="true"/></td>
</tr>
<tr>
<td bgcolor="#0099FF">3</td>
<td bgcolor="#0099FF">Ikan Laut Bakar</td>
<td bgcolor="#0099FF">@<input type="text" name="bakar3" value="25000" size="15" disabled="true"/></td>
<td bgcolor="#0099FF"><input type="text" name="inp3" value="0" onChange="hitung()"/></td>
<td><input type="text" name="bayar3" disabled="true"/></td>
</tr>
<tr>
<td bgcolor="#0099FF">4</td>
<td bgcolor="#0099FF">Es Rumput Laut</td>
<td bgcolor="#0099FF">@<input type="text" name="minum1" value="7000" size="15" disabled="true"/></td>
<td bgcolor="#0099FF"><input type="text" name="inp4" value="0" onChange="hitung()"/></td>
<td><input type="text" name="bayar4" disabled="true"/></td>
</tr>
<tr>
<td bgcolor="#0099FF">5</td>
<td bgcolor="#0099FF">Es Degan</td>
<td bgcolor="#0099FF">@<input type="text" name="minum2" value="7000" size="15" disabled="true"/></td>
<td bgcolor="#0099FF"><input type="text" name="inp5" value="0" onChange="hitung()"/></td>
<td><input type="text" name="bayar5" disabled="true"/></td>
</tr>
<tr>
<td colspan="4" align="right" bgcolor="#FF0000">Jumlah Total</td>
<td><input type="text" name="Total" disabled="true" /></td>
</tr>
<tr>
<td colspan="4" align="right" bgcolor="#FFFFFF">Diskon</td>
<td><input type="text" name="Diskon" disabled="true" /></td>
</tr>
<tr>
<td colspan="4" align="right" bgcolor="#FFFF00">Jumlah Dibayar</td>
<td><input type="text" name="Bayar" disabled="true" align="right"/></td>
</tr>
</table>
<br/>
<input type="reset" value="Batal" />
</div>
</form>
</body>
</html>