Senin, 07 Maret 2011

Tugas Praktikum Modul 5

<!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">
<head>
<title>Tugas Praktikum Modul 5</title>
<script language="JavaScript" type="text/javascript" src="pembelian.js"></script>
</head>
<center>
<body bgcolor="white">
<h1>Form Pembelian</h1>
<form name="HitungPesan" action="#">
<table bpesanan="1">
<tr>

<th>No</th>
<th>Makanan / Minuman</th>
<th>Harga</th>
<th>Pesan</th>
</tr>
<tr>
<td>1</td>
<td>Soto Ayam</td>
<td>@<input type="text" name="harga1" value="8000" onchange="hitung()"/></td>
<td><input type="text" name="pesanan1" onchange="hitung()"/></td>
</tr>
<tr>
<td>2</td>
<td>Nasi Goreng</td>
<td>@<input type="text" name="harga2" value="6000" onchange="hitung()"/></td>
<td><input type="text" name="pesanan2" onchange="hitung()"/></td>
</tr>
<tr>
<td>3</td>
<td>lalapan</td>
<td>@<input type="text" name="harga3" value="5000" onchange="hitung()"/></td>
<td><input type="text" name="pesanan3" onchange="hitung()"/></td>
</tr>
<tr>
<td>4</td>
<td>Es Teh</td>
<td>@<input type="text" name="harga4" value="1000" onchange="hitung()"/></td>
<td><input type="text" name="pesanan4" onchange="hitung()"/></td>
</tr>
<tr>
<td>5</td>
<td>Juice Campur</td>
<td>@<input type="text" name="harga5" value="7000" onchange="hitung()"/></td>
<td><input type="text" name="pesan5" onchange="hitung()"/></td>
</tr>
<tr>
<td colspan="3" align="right">Jumlah Total</td>
<td><input type="text" name="total" Value="0" readonly /></td>
</tr>
<tr>
<td colspan="3" align="right">Diskon</td>
<td><input type="text" name="diskon" value="0" readonly /></td>
</tr>
<tr>
<td colspan="3" align="right">Jumlah Dibayar</td>
<td><input type="text" name="bayar" value="0" readonly /></td>
</tr>
</table>
<br>
<input type="button" name="Hitung" value="Hitung" onclick="reset()"/>
<br>
<input type="button" name="batal" value="Batal" onclick="reset()"/>
</form>
</body>
</html>

Studi kasus Modul 5

SCIPRT :
<!DOCTYPE HTML>
<html lang="en">
<head>
<title><H1>Kalkulator Tugas Praktikum></H1></title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
function kalkulator(){
var myForm = document.form1;
var a=eval(myForm.a.value);
var b=eval(myForm.b.value);
var pil= myForm.opt.value;
if (pil == "penjumlahan") {
    var c = a + b;
 }else if (pil == "pengurangan") {
    var c = a - b;
 } else if (pil == "perkalian") {
    var c = a * b;
 } else if (pil == "pembagian") {
    var c = a / b;
 }
 myForm.total.value = c;
}
function resetForm(){
document.form1.reset();
}

//-->
</script>
<center>
<font size= ”5"> Kalkulator Tugas Praktikum </font>
<br>
<br>

<form name="form1" action="#">
<input type="text" name="a" />
<select name="opt">
 <option value="penjumlahan"> + </option>
 <option value="pengurangan"> - </option>
 <option value="perkalian"> * </option>
 <option value="pembagian"> / </option>
</select>
<input type="text" name="b" />
<input type="button" value="=" onClick="kalkulator()" />
<input type="text" name="total" disabled="true" /> <br/>
<p>
<input type="button" value="CLEAR" onClick="resetForm()" />

</form>
</body>
</html>