Sekarang saya akan membagi contoh coding untuk JSP bagi para pemula seperti saya ^^. Coding ini sederhana hanya menggunakan aspek kode pada HTML dan ekstensi file-nya pun html. Oh ya!! terapkan kode ini pada Software NetBeans .. bagi yang belum memiliki silahkan di download di halaman ini. <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Combo</title>
<style type="text/css"><!--
body {
background-image : url("1325914240570.jpg")
}
--></style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<script language="javascript">
function pilihan()
{
var bil1=document.ulfa.cmbpil.value;
var jenis=0;
var kd_tiket=0;
var harga=0;
switch(bil1)
{
case 'NTP01':
jenis = 'Eksekutif';
harga =750000; break;
case 'NTP02':
jenis = 'Bisnis';
harga =1500000; break;
case 'NTP03':
jenis = 'Ekonomi';
harga =2000000; break;
case 'NTP04':
jenis = 'VIP';
harga =4500000; break;
default:
jenis =0;
harga =0;
}
document.ulfa.txtharga.value=harga
document.ulfa.txtjenis.value=jenis
}
function count()
{
if(document.ulfa.txtnama.value=="")
{alert("It's Empty")
return false;}
if(document.ulfa.txtno_ktp.value=="")
{alert("It's Empty")
return false;}
if(document.ulfa.txtjml_tiket.value=="")
{alert("It's Empty")
return false;}
if(isNaN(document.ulfa.txtno_ktp.value))
{alert("It's Not Number")
document.ulfa.txtno_ktp.value=="";
return false;}
if(isNaN(document.ulfa.txtjml_tiket.value))
{alert("It's Not Number")
document.ulfa.txtjml_tiket.value=="";
return false;}
var harga=parseInt(document.ulfa.txtharga.value)
var jml_tiket=parseInt(document.ulfa.txtjml_tiket.value)
var total=harga*jml_tiket;
document.ulfa.txttotal.value=total
}</script>
<form id="form1" name="ulfa" method="post" action="">
<center><font face="Calibri" size="7" color="white">Garuda Indonesia</font></center><br>
<center><font face="Calibri" size="6" color="white">Tiket Penerbangan</font></center><br>
<center> <table width="365" border="0">
<tr>
<td width="151"><font face="Calibri" size="5" color="white">Kode: </font></td>
<td widh="198"><label>
<select name="cmbpil" OnChange="pilihan()" id="cmbpil">
<option>NTP01</option>
<option>NTP02</option>
<option>NTP03</option>
</select>
</label></td>
</tr>
<tr><td><font face="Calibri" size="5" color="white">Jenis:</font></td><td><label><input name="txtjenis" type="text" readonly="readonly" id="txtjenis"/></label></td></tr>
<tr><td><font face="Calibri" size="5" color="white">Harga:</font></td><td><label><input name="txtharga" type="text" readonly="readonly" id="txtharga"/></label></td></tr>
<tr><td><font face="Calibri" size="5" color="white">Nama:</font></td><td><label><input name="txtnama" type="text" id="txtnama"/></label></td></tr>
<tr><td><font face="Calibri" size="5" color="white">NoKTP :</font></td><td><label><input name="txtno_ktp" type="text" id="txtno_ktp"/></label></td></tr>
<tr><td><font face="Calibri" size="5" color="white">Dari :</font></td><td><label><input name="txtp" type="text" id="txtp"/></label></td><td><font face="Calibri" size="5" color="white">Ke</font></td><td>:</td><td><label><input name="txtm" type="text" id="txtm"/></label></td></tr>
<tr><td><font face="Calibri" size="5" color="white">Jumlah:</font></td><td><label><input name="txtjml_tiket" type="text" id="txtjml_tiket"/></label></td></tr>
<tr><td><font face="Calibri" size="5" color="white">Total:</font></td><td><label><input name="txttotal" type="text" readonly="readonly" id="txttotal"/></label></td></tr>
<tr><td><font face="Calibri" size="5" color="white">Tanggal:</font></td><td><label><input name="txtbrgkt" type="text" readonly="readonly" id="txtbrgkt"/></label></td></tr>
<tr>
<td width="151"><font face="Calibri" size="5" color="white">Bank : </font></td>
<td widh="198"><label>
<select name="bank" >
<option>BCA</option>
<option>BNI</option>
<option>Mandiri</option>
</select>
</label></td>
</tr>
</table>
<br>
<p><label><input name="bttcount" type="button" OnClick="count()" id="bttcount" value="Count"/>
</label>
<label><input name="btreset" type="reset" id="bttreset" value="Reset"/> </label></p>
<br>
<br>
</form>
</body>
</html>
0 komentar:
Posting Komentar