tugas 1 praktium
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Array 2 dimensi dinamis</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<style type="text/css">
.badan{background-color:#00FFFF;}
</style>
<body>
<script type="text/javascript">
var produk = new Array();
var y = 0;
var i;
var a;
function include()
{
produk[y]=new Array();
produk[y][0]=document.getElementById("produk").value;
produk[y][1]=+document.getElementById("harga").value;
y++
isi = "";
for(i=0;i<produk.length;i++)
{
for(a=0;a<2;a++)
{
isi += produk[i][a]+" ";
}
isi += "<br>";
}
document.getElementById("hasil").innerHTML = isi;
document.getElementById("produk").value = "";
document.getElementById("harga").value = "";
}
function tt()
{
sum = 0;
jumlah = document.getElementById("jumlah").value;
for (s=0;s<produk.length;s++)
{
sum += produk[s][1]*jumlah;
}
document.getElementById("ka").innerHTML = "Harga Keseluruhan = Rp. "+sum;
document.getElementById("jumlah").value="";
}
</script>
<h1 align="center">PRODUK PENJUALAN</h1>
<table align="center" border="2px" class="badan" width="700px" height="400px">
<tr>
<td>
<table align="center">
<tr>
<td><label>Nama Produk</label></td>
<td>: <input type="text" id="produk"></td>
</tr>
<tr>
<td><label>Harga</label></td>
<td>: <input type="text" id="harga"></td>
</tr>
<tr>
<td><label>Jumlah</label></td>
<td>: <input type="text" id="jumlah"></td>
</tr>
</table>
<center><input type="button" value="Tambahkan" onClick="include()"><input type="button" value="Jumlah Harga" onClick="tt()"></center>
<center><label id="hasil"></label></center>
<center><label id="ka"></label></center>
</td>
</tr>
</table>
</body>
</html>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Array 2 dimensi dinamis</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<style type="text/css">
.badan{background-color:#00FFFF;}
</style>
<body>
<script type="text/javascript">
var produk = new Array();
var y = 0;
var i;
var a;
function include()
{
produk[y]=new Array();
produk[y][0]=document.getElementById("produk").value;
produk[y][1]=+document.getElementById("harga").value;
y++
isi = "";
for(i=0;i<produk.length;i++)
{
for(a=0;a<2;a++)
{
isi += produk[i][a]+" ";
}
isi += "<br>";
}
document.getElementById("hasil").innerHTML = isi;
document.getElementById("produk").value = "";
document.getElementById("harga").value = "";
}
function tt()
{
sum = 0;
jumlah = document.getElementById("jumlah").value;
for (s=0;s<produk.length;s++)
{
sum += produk[s][1]*jumlah;
}
document.getElementById("ka").innerHTML = "Harga Keseluruhan = Rp. "+sum;
document.getElementById("jumlah").value="";
}
</script>
<h1 align="center">PRODUK PENJUALAN</h1>
<table align="center" border="2px" class="badan" width="700px" height="400px">
<tr>
<td>
<table align="center">
<tr>
<td><label>Nama Produk</label></td>
<td>: <input type="text" id="produk"></td>
</tr>
<tr>
<td><label>Harga</label></td>
<td>: <input type="text" id="harga"></td>
</tr>
<tr>
<td><label>Jumlah</label></td>
<td>: <input type="text" id="jumlah"></td>
</tr>
</table>
<center><input type="button" value="Tambahkan" onClick="include()"><input type="button" value="Jumlah Harga" onClick="tt()"></center>
<center><label id="hasil"></label></center>
<center><label id="ka"></label></center>
</td>
</tr>
</table>
</body>
</html>

Komentar
Posting Komentar