Selasa, 01 Maret 2011

script form bayar utang tugas rumah modul 5 java script. dwi sagitta tjipta 209533421964

<em><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>form bayar utang</title>
<link rel="stylesheet" href="mystyle.css" type="text/css" />
<header>
<img src="logo um copy transparant 600px.png" width="100px" height="100px" />
<img src="sensuspenduduk.png" width="333" height="100px" />

</header>
</head>
<script language="JavaScript" type="text/javascript">
function ngebond(){
var kertas = document.formulir;
var hargaBakso = 12000 * eval(kertas.Bakso.value);
var hargaSoto = 10000 * eval(kertas.Soto.value);
var hargaMie = 15000 * eval(kertas.Mie.value);
var hargaDegan = 5000 * eval(kertas.Degan.value);
var hargaCampur = 7000 * eval(kertas.Campur.value);
var TotalHarga = hargaBakso + hargaSoto + hargaMie + hargaDegan + hargaCampur;
if (TotalHarga > 50000){
kertas.Total.value = TotalHarga;
kertas.Diskon.value = 10000;
kertas.Bayar.value = TotalHarga - eval(kertas.Diskon.value);
} else {
kertas.Total.value = TotalHarga;
kertas.Diskon.value = 0;
kertas.Bayar.value = TotalHarga - eval(kertas.Diskon.value);
}
}
function resetForm(){
document.formulir.reset();
}
</script>

<body background="3C60C395125F4.JPG">

<H2>Form Pemesanan Makan dan Minum</H2>
<form name="formulir" action="#">
<table border="1px">
<tr>
<th>No</th>
<th>Makanan/Minuman</th>
<th>Harga</th>
<th>Pesan</th>
</tr>

<tr>
<td width="20" >1</td>
<td width="180">Bakso Istimewa</td>
<td width="130" > @&nbsp<input type="text" name="bakso" value="12000" size="7" readonly="readonly"/></td>
<td width="160"><input type="text" name="Bakso" value="0" onFocus="this.select()" onChange="ngebond()"/></td>
</tr>

<tr>
<td>2</td>
<td>Soto Spesial</td>
<td> @&nbsp<input type="text" name="soto" value="10000" size="7" readonly="readonly"/></td>
<td><input type="text" name="Soto" value="0" onFocus="this.select()" onChange="ngebond()"/></td>
</tr>
<tr>
<td>3</td>
<td>Mie Ayam Super</td>
<td> @&nbsp <input type="text" name="mie" value="15000" size="7" readonly="readonly"/></td>
<td><input type="text" name="Mie" value="0" onFocus="this.select()" onChange="ngebond()"/></td>
</tr>
<tr>
<td>4</td>
<td>Es Degan</td>
<td> @&nbsp <input type="text" name="degan" value="7000" size="7" readonly="readonly"/></td>
<td><input type="text" name="Degan" value="0" onFocus="this.select()" onChange="ngebond()"/></td>
</tr>
<tr>
<td>5</td>
<td>Es Campur</td>
<td> @&nbsp <input type="text" name="campur" value="7000" size="7" readonly="readonly"/></td>
<td><input type="text" name="Campur" value="0" onFocus="this.select()" onChange="ngebond()"/></td>
</tr>
<tr>
<td colspan="3" align="right">Jumlah Total</td>
<td><input type="text" name="Total" readonly="readonly" /></td>
</tr>
<tr>
<td colspan="3" align="right">Diskon</td>
<td><input type="text" name="Diskon" readonly="readonly"/></td>
</tr>
<tr>
<td colspan="3" align="right">Jumlah Dibayar</td>
<td><input type="text" name="Bayar" readonly="readonly" align="right"/></td>
</tr>
</table><br/>
<input type="button" value="CLEAR" onClick="resetForm()" />
</form>
</body>
</html></em>

Tidak ada komentar:

Posting Komentar