Jumat, 01 Juni 2012
Javascript Percabangan
<html>
<head><title>Percabangan</title></head>
<body>
<script language="javascript">
<!--
function hitungtotal(){
var nama = (document.fform.inama.value);
var tujuan = (document.fform.itujuan.value);
var jumlahpaket = (document.fform.ijumlahpaket.value);
var ht = 0.0;
var sub = 0.0;
var diskon = 0.0;
var total = 0.0;
if (tujuan=="Jakarta")
{
ht =10000;
}
else if (Tujuan=="Yogyakarta")
{
ht =50000;
}
else
{
ht =20000;
}
sub = jumlahpaket*ht;
if (document.fform.imember.checked==true)
{
diskon =0.10*sub;
}
else
{
diskon =0.0;
}
total = sub-diskon;
document.fform.otiket.value==eval(ht);
document.fform.osub.value==eval(sub);
document.fform.odiskon.value==eval(diskon);
document.fform.ototal.value==eval(total);
// gunakan mengecek !!! alert (total);
}
//--></script>
<form name="fform">
<table border="1" align="center" width="70%">
<tr><td width="50%"><pre>
Nama :<input type="text" size="20" name="inama">
Tujuan :<select name="itujuan" size="1">
<option value="Jakarta">Jakarta</option>
<option value="Yogyakarta">Yogyakarta</option>
<option value="semarang">Semarang</option>
</select>
Jumlah Tiket :<input type="text" size="11" name="ijumlah">
Member :<input type="checkbox" name="imember">Ya</td></pre>
<td width="50%"><pre>
harga Tiket :<input type="text" size="10" name="otiket">
sub total :<input type="text" size="10" name="osub">
Diskon :<input type="text" size="10" name="odiskon">
Total Bayar :<input type="text" size="10" name="ototal"></pre></td>
</tr>
<td width="100%" colspan="2">
<center>
<input type="button" value="hitung" onclick="hitungtotal()">
<input type="reset" value="ulang">
</center></td>
</table></form>
<img src="Uchiha_wall_by_Pajadox.jpg">
</body>
</html>
jika dilihat hasilnya
Semoga Bermanfaat (^_^)
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar