Minggu, 13 Maret 2011
MODUL 6 - STUDI KASUS (GENERATE TABLE)
Pada studi kasus ini membuat tabel dengan fungsi sederhana untuk men-generate matriks sel pada tabel.
misalkan diberikan argumen 5 (baris) dan 5 (kolom), maka program akan menampilkan tabel dengan 5 baris dan 5 kolom.
SOURCECODE :
<!DOCTYPE html>
<html lang="en">
<head>
<title>Generate Table</title>
</head>
<body bgcolor="white">
<center>
<h1>FUNCTION GENERATE TABLE</h1>
<h3>membuat table dengan inputan argumen</h3>
<hr />
<br>
<br>
<?php
function Create_table($baris, $kolom)
{
echo("<table border=\"1\">\n");
for($b = 0; $b < $baris; $b++) {
echo("<tr height=\"30px\">\n");
for($k = 0; $k < $kolom; $k++) {
echo("<td width=\"100px\"></td>\n");
}
echo("</tr>\n");
}
echo("</table>\n");
echo("<h3>Tabel : $baris baris dan $kolom kolom</h3>");
}
Create_table(5,5);
?>
</center>
</body>
</html>
begitu pula denga membuat 7 baris dan 5 kolom
maka cukup dengan mengubah Create_table(7,5);
misalkan diberikan argumen 5 (baris) dan 5 (kolom), maka program akan menampilkan tabel dengan 5 baris dan 5 kolom.
SOURCECODE :
<!DOCTYPE html>
<html lang="en">
<head>
<title>Generate Table</title>
</head>
<body bgcolor="white">
<center>
<h1>FUNCTION GENERATE TABLE</h1>
<h3>membuat table dengan inputan argumen</h3>
<hr />
<br>
<br>
<?php
function Create_table($baris, $kolom)
{
echo("<table border=\"1\">\n");
for($b = 0; $b < $baris; $b++) {
echo("<tr height=\"30px\">\n");
for($k = 0; $k < $kolom; $k++) {
echo("<td width=\"100px\"></td>\n");
}
echo("</tr>\n");
}
echo("</table>\n");
echo("<h3>Tabel : $baris baris dan $kolom kolom</h3>");
}
Create_table(5,5);
?>
</center>
</body>
</html>
begitu pula denga membuat 7 baris dan 5 kolom
maka cukup dengan mengubah Create_table(7,5);
MODUL 6 - STUDI KASUS (FUNGSI GREETING)
SOURCE CODE :
<!DOCTYPE html>
<html lang="en">
<head>
<title>Greeting</title>
</head>
<body bgcolor="green">
<center>
<h1>ADA YANG BILANG JELEK KU GAK PEDULI</h1>
<hr />
<img src="images/banyuwangi.png">
<?php
$d=date("G");
if ($d > "0" && $d < "6") {
echo "<<h1>Selamat Subuh</h1>". date("G");
echo "<h2>Selamat Datang di SIMPLE LAREOSING</h2>";
echo "<h3>Sekarang adalah hari ". date("l"). " tanggal ". date("d m Y");
echo "<br>Waktu menunjukkan pukul ". date("H:i"). " WIB";
}
elseif ($d > "6" && $d < "12") {
echo "<h1>Selamat pagi</h1>";
echo "<h2>Selamat Datang di SIMPLE LAREOSING</h2>";
echo "<h3>Sekarang adalah hari ". date("l"). " tanggal ". date("d m Y");
echo "<br>Waktu menunjukkan pukul ". date("H:i"). " WIB";
}
elseif ($d > "12" && $d < "18"){
echo "<h1>Selamat Siang</h1>";
echo "<h2>Selamat Datang di SIMPLE LAREOSING</h2>";
echo "<h3>Sekarang adalah hari ". date("l"). " tanggal ". date("d m Y");
echo "<br>Waktu menunjukkan pukul ". date("H:i"). " WIB";
}
else {
echo "<h1>Selamat Malam</h1>";
echo "<h2>Selamat Datang di SIMPLE LAREOSING</h2>";
echo "<h3>Sekarang adalah hari ". date("l"). " tanggal ". date("d m Y");
echo "<br>Waktu menunjukkan pukul ". date("H:i"). " WIB";
}
?>
</center>
</body>
</html>
Sabtu, 05 Maret 2011
MODUL 5 - TUGAS PRAKTIKUM
Program Kasir Warung
tampilan awal
setelah di klik batal
warung.css
body {
margin: 10px auto;
width: 580px;
}
header,section,footer{
display:block;
border:1px solid blue;
}
header{
height:60px;
background : #4380d4;
}
section{
padding: 10px;
height:400px;
}
footer{
clear:both;
height:20px;
background : #4380d4;
}
warung.js
function JumlahTotal(){
var myForm=document.form1;
var total1;
var total2;
var total3;
var total4;
var total5;
total1 =parseInt(myForm.harga1.value) * parseInt(myForm.pesan1.value);
total2 =parseInt(myForm.harga2.value) * parseInt(myForm.pesan2.value);
total3 =parseInt(myForm.harga3.value) * parseInt(myForm.pesan3.value);
total4 =parseInt(myForm.harga4.value) * parseInt(myForm.pesan4.value);
total5 =parseInt(myForm.harga5.value) * parseInt(myForm.pesan5.value);
myForm.JumTotal.value=total1+total2+total3+total4+total5;
}
function potongan(){
var myForm=document.form1;
if (myForm.JumTotal.value < 50000){
myForm.Diskon.value = 0;
}
else{
myForm.Diskon.value = 10000;
}
}
function JumlahBayar(){
var myForm=document.form1;
myForm.JumBayar.value = myForm.JumTotal.value - myForm.Diskon.value ;
}
function proses(){
JumlahTotal();
potongan();
JumlahBayar();
reset();
}
function reset(){
var elemen = document.pemesanan;
elemen.pesan1.value = "";
elemen.pesan2.value = "";
elemen.pesan3.value = "";
elemen.pesan4.value = "";
elemen.pesan5.value = "";
elemen.total.value = "";
elemen.diskon.value = "";
elemen.bayar.value = "";
}
warung.html
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Warung Rung</title>
<script language="JavaScript" type="text/javascript" src="warung.js"></script>
<link rel="stylesheet" href="warung.css" type="text/css" />
</head>
<body>
<header>
<h1 align="center">WARUNG RUNG</h1>
</header>
<section>
<form name="form1" action="#">
<table border=1 cellpadding=3>
<tr>
<th>No.</th>
<th width = 200px >Makanan / Minuman </th>
<th width = 200px >Harga</th>
<th>Pesan</th>
</tr>
<tr>
<td>1</td>
<td>Bakso Istimewa </td>
<td>@<input type="text" name="harga1" value="12000" readonly /></td>
<td><input type="text" name="pesan1" value="0" onChange ="proses()"/></td>
</tr>
<tr>
<td>2</td>
<td>Soto Spesial </td>
<td>@<input type="text" name="harga2" value="10000" readonly /></td>
<td><input type="text" name="pesan2" value="0" onChange ="proses()" /></td>
</tr>
<tr>
<td>3</td>
<td>Mie Ayam Super </td>
<td>@<input type="text" name="harga3" value="15000" readonly /></td>
<td><input type="text" name="pesan3" value="0" onChange ="proses()" /></td>
</tr>
<tr>
<td>4</td>
<td>Es Degan </td>
<td>@<input type="text" name="harga4" value="5000" readonly /></td>
<td><input type="text" name="pesan4" value="0" onChange ="proses()" /></td>
</tr>
<tr>
<td>5</td>
<td>Es Campur </td>
<td>@<input type="text" name="harga5" value="7000" readonly /></td>
<td><input type="text" name="pesan5" value="0" onChange ="proses()" /></td>
</tr>
<tr>
<td colspan=3>Jumlah</td>
<td><input type="text" name="JumTotal" readonly /></td>
<tr>
<tr>
<td colspan=3>Diskon</td>
<td><input type="text" name="Diskon" readonly /></td>
<tr>
<tr>
<td colspan=3>Jumlah Dibayar</td>
<td><input type="text" name="JumBayar" readonly /></td>
<tr>
</table>
<br>
<!--<input type="button" value="Proses" onclick="proses()" />-->
<input type="button" name="batal" value="Batal" onclick="reset()"/>
</form>
</section>
<footer>
<center> © alifable </center>
</footer>
</body>
</html>
tampilan awal
setelah di klik batal
warung.css
body {
margin: 10px auto;
width: 580px;
}
header,section,footer{
display:block;
border:1px solid blue;
}
header{
height:60px;
background : #4380d4;
}
section{
padding: 10px;
height:400px;
}
footer{
clear:both;
height:20px;
background : #4380d4;
}
warung.js
function JumlahTotal(){
var myForm=document.form1;
var total1;
var total2;
var total3;
var total4;
var total5;
total1 =parseInt(myForm.harga1.value) * parseInt(myForm.pesan1.value);
total2 =parseInt(myForm.harga2.value) * parseInt(myForm.pesan2.value);
total3 =parseInt(myForm.harga3.value) * parseInt(myForm.pesan3.value);
total4 =parseInt(myForm.harga4.value) * parseInt(myForm.pesan4.value);
total5 =parseInt(myForm.harga5.value) * parseInt(myForm.pesan5.value);
myForm.JumTotal.value=total1+total2+total3+total4+total5;
}
function potongan(){
var myForm=document.form1;
if (myForm.JumTotal.value < 50000){
myForm.Diskon.value = 0;
}
else{
myForm.Diskon.value = 10000;
}
}
function JumlahBayar(){
var myForm=document.form1;
myForm.JumBayar.value = myForm.JumTotal.value - myForm.Diskon.value ;
}
function proses(){
JumlahTotal();
potongan();
JumlahBayar();
reset();
}
function reset(){
var elemen = document.pemesanan;
elemen.pesan1.value = "";
elemen.pesan2.value = "";
elemen.pesan3.value = "";
elemen.pesan4.value = "";
elemen.pesan5.value = "";
elemen.total.value = "";
elemen.diskon.value = "";
elemen.bayar.value = "";
}
warung.html
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Warung Rung</title>
<script language="JavaScript" type="text/javascript" src="warung.js"></script>
<link rel="stylesheet" href="warung.css" type="text/css" />
</head>
<body>
<header>
<h1 align="center">WARUNG RUNG</h1>
</header>
<section>
<form name="form1" action="#">
<table border=1 cellpadding=3>
<tr>
<th>No.</th>
<th width = 200px >Makanan / Minuman </th>
<th width = 200px >Harga</th>
<th>Pesan</th>
</tr>
<tr>
<td>1</td>
<td>Bakso Istimewa </td>
<td>@<input type="text" name="harga1" value="12000" readonly /></td>
<td><input type="text" name="pesan1" value="0" onChange ="proses()"/></td>
</tr>
<tr>
<td>2</td>
<td>Soto Spesial </td>
<td>@<input type="text" name="harga2" value="10000" readonly /></td>
<td><input type="text" name="pesan2" value="0" onChange ="proses()" /></td>
</tr>
<tr>
<td>3</td>
<td>Mie Ayam Super </td>
<td>@<input type="text" name="harga3" value="15000" readonly /></td>
<td><input type="text" name="pesan3" value="0" onChange ="proses()" /></td>
</tr>
<tr>
<td>4</td>
<td>Es Degan </td>
<td>@<input type="text" name="harga4" value="5000" readonly /></td>
<td><input type="text" name="pesan4" value="0" onChange ="proses()" /></td>
</tr>
<tr>
<td>5</td>
<td>Es Campur </td>
<td>@<input type="text" name="harga5" value="7000" readonly /></td>
<td><input type="text" name="pesan5" value="0" onChange ="proses()" /></td>
</tr>
<tr>
<td colspan=3>Jumlah</td>
<td><input type="text" name="JumTotal" readonly /></td>
<tr>
<tr>
<td colspan=3>Diskon</td>
<td><input type="text" name="Diskon" readonly /></td>
<tr>
<tr>
<td colspan=3>Jumlah Dibayar</td>
<td><input type="text" name="JumBayar" readonly /></td>
<tr>
</table>
<br>
<!--<input type="button" value="Proses" onclick="proses()" />-->
<input type="button" name="batal" value="Batal" onclick="reset()"/>
</form>
</section>
<footer>
<center> © alifable </center>
</footer>
</body>
</html>
MODUL 5 - STUDI KASUS
Membuat Calculator Sederhana
cal.js
function proses(){
var myForm=document.form1;
if (myForm.operasi.value == "+"){
myForm.hasil.value = parseInt(myForm.bil1.value) + parseInt(myForm.bil2.value);
}
else if (myForm.operasi.value == "-"){
myForm.hasil.value = parseInt(myForm.bil1.value) - parseInt(myForm.bil2.value);
}
else if (myForm.operasi.value == "*"){
myForm.hasil.value = parseInt(myForm.bil1.value) * parseInt(myForm.bil2.value);
}
else {
myForm.hasil.value = parseInt(myForm.bil1.value) / parseInt(myForm.bil2.value);
}
}
cal.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Simple Calculator</title>
<script language="JavaScript" type="text/javascript" src="cal.js"></script>
</head>
<body bgcolor="#4380d4">
<center>
<h1> SIMPLE CALCULATOR</h1>
<form name=form1 action="#">
<table border="1">
<tr>
<td>Bilangan1 <input type="text" name="bil1"/></td>
</tr>
<tr>
<td align="center"><select name="operasi" >
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
</td>
</tr>
<tr>
<td>Bilangan2 <input type="text" name="bil2" /></td>
</tr>
<tr>
<td align="center"><input type="button" value="=" onclick="proses()" /></td>
</tr>
<tr>
<td>Hasil
<input type="text" name="hasil" /></td>
</tr>
</table>
</form>
<br>
© alifable
</center>
</body>
</html>
cal.js
function proses(){
var myForm=document.form1;
if (myForm.operasi.value == "+"){
myForm.hasil.value = parseInt(myForm.bil1.value) + parseInt(myForm.bil2.value);
}
else if (myForm.operasi.value == "-"){
myForm.hasil.value = parseInt(myForm.bil1.value) - parseInt(myForm.bil2.value);
}
else if (myForm.operasi.value == "*"){
myForm.hasil.value = parseInt(myForm.bil1.value) * parseInt(myForm.bil2.value);
}
else {
myForm.hasil.value = parseInt(myForm.bil1.value) / parseInt(myForm.bil2.value);
}
}
cal.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Simple Calculator</title>
<script language="JavaScript" type="text/javascript" src="cal.js"></script>
</head>
<body bgcolor="#4380d4">
<center>
<h1> SIMPLE CALCULATOR</h1>
<form name=form1 action="#">
<table border="1">
<tr>
<td>Bilangan1 <input type="text" name="bil1"/></td>
</tr>
<tr>
<td align="center"><select name="operasi" >
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
</td>
</tr>
<tr>
<td>Bilangan2 <input type="text" name="bil2" /></td>
</tr>
<tr>
<td align="center"><input type="button" value="=" onclick="proses()" /></td>
</tr>
<tr>
<td>Hasil
<input type="text" name="hasil" /></td>
</tr>
</table>
</form>
<br>
© alifable
</center>
</body>
</html>
Langganan:
Postingan (Atom)