Kamis, 21 September 2017
<html>
<head>
<title>Program rekening listrik</title>
<script>
function RekeningListrik()
{
var totPemakaian;
var hargaPerKwH;
var totPembayaran;
//1. Input total pemakaian
totPemakaian = InputData ("txtTotalPemakaian");
//2. Input harga per KwH
hargaPerKwH = InputData("txtHarga");
//3. Hitung total pembayaran
totPembayaran = TotalPembayaran(totPemakaian,hargaPerKwH);
//4. Tampilakan Total Pembayaran
}
function TotalPembayaran(totalPemakaian,haragPerKwH)
{
var totalPembayaran;
totalPembayaran = parseInt(totalPemakaian * hargaPerKwH);
return totalPembayaran;
}
</script>
</head>
<body>
<script>
function OutputData(keluaran)
{
document.getElementatById("lblTotalTagihan").innerHTML = keluaran;
}
function InputData (namaKomponen)
{
var data;
data = document.getElementatById(namaKomponen).value;return data;
}
<div>
<div>
<label>Total Pemakaian </label>
<input type="text" id="txtTotalPemakaian"/>
</div>
<div>
<label>Harga per KwH </label>
<input type="text" id="txtHarga"/>
</div>
<div>
<label>Total Tagihan </label>
<label id="lblTotalTagihan">0</label>
</div>
<div>
<input type="button" id="btnHitung" value="Hitung" onclick="RekeningListrik"()"/>
</div>
</div>
</body>
</html>
Kamis, 31 Agustus 2017
<!DOCTYPE html>
<html>
<head>
<title>Penjumlahan 2 Variabel</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.box {
width: 40%;
border-radius: 5px;
border: 1px solid #9b9b9b;
padding: 20px 0px 20px 0px;
margin-left: 30%;
}
.h2{
font-family: calibri;
font-weight: lighter;
letter-spacing: 3px;
}
#bil1{
padding: 5px;
}
#bil2{
padding: 5px;
}
#hasil{
color: #ff0b0b;
}
</style>
</head>
<body>
<div class="box">
<center>
<h2 class="h2">Aplikasi Penjumlahan 2 bilangan</h2>
<div class="box1">
<label>Bil 1</label>
<input type="text" id="bil1" placeholder="Masukan bilangan 1">
</div>
<br>
<div class="box2">
<label>Bil 2</label>
<input type="text" id="bil2" placeholder="Masukan bilangan 2">
</div>
<div class="box3">
<label>Hasil</label>
<label id="hasil"></label>
</div>
<br>
<input type="button" id="btn" value="Jumlah" class="btn" onClick="jumlah()">
</center>
</div>
<script>
function jumlah(){
var a = document.getElementById("bil1").value;
var b = document.getElementById("bil2").value;
document.getElementById("hasil").innerHTML = parseFloat(a) + parseFloat(b);
}
</script>
</body>
</html>
Langganan:
Postingan (Atom)