0% found this document useful (0 votes)
9 views3 pages

00 Harga 1

Uploaded by

lidanindah.video
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

00 Harga 1

Uploaded by

lidanindah.video
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

<!

DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Form Input</title>
<style>
/* Form */
form {
width: 300px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
}

input {
width: 100%;
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}

button {
width: 100%;
height: 40px;
background-color: #000;
color: #fff;
font-weight: bold;
border: none;
cursor: pointer;
margin-top: 20px;
}

/* Alert */
.alert {
width: 300px;
margin: 0 auto;
padding: 10px;
border-radius: 5px;
background-color: #f0f0f0;
color: #000;
position: relative;
top: 100px;
}

/* Tambahan CSS */

/* Warna tulisan */
input, button {
color: #000;
}

/* Ukuran font */
input, button {
font-size: 16px;
}

/* Font family */
input, button {
font-family: sans-serif;
}

/* Shadow */
form {
box-shadow: 0 0 10px 0 #ccc;
}

/* Tampilan di tengah */
form {
display: flex;
justify-content: center;
}

/* Pemisah ribuan */
.alert p {
text-align: center;
font-size: 16px;
font-weight: bold;
font-family: sans-serif;
color: #000;
margin-bottom: 0;
}

.alert p span {
float: right;
font-size: 12px;
}
</style>
</head>
<body>
<form action="" method="post">
<input type="text" name="input" placeholder="Masukkan Jumlah SMS">
<button type="submit">Hitung</button>
</form>

<script>
function hitung() {
// Ambil nilai input
var input = document.querySelector("input[name='input']").value;

// Validasi input
if (input < 1000) {
alert("Nilai minimal adalah 1.000");
return;
}

// Hitung hasil
var hasil = 0;
if (input <= 4999) {
hasil = input * 418;
} else if (input <= 9999) {
hasil = input * 410;
} else if (input <= 24999) {
hasil = input * 405;
} else if (input <= 49999) {
hasil = input * 400;
} else if (input <= 99999) {
hasil = input * 395;
} else {
hasil = input * 390;
}

// Tampilkan hasil dalam bentuk alert


alert("Hasil : " + hasil.toLocaleString("id-ID"));
}

document.querySelector("button").addEventListener("click", hitung);
</script>
</body>
</html>

You might also like