You are on page 1of 3

<!

DOCTYPE html>
<html>
<head>
<title>UTS PBP thn 17/18 no 1</title>
<script type="text/javascript">
function validateform(){
if(document.forms["form-group"]["nama"].value == ""){
alert("Please fill all the form");
return false;
}
if(document.forms["form-group"]["harga"].value == ""){
alert("Please fill all the form");
return false;
}
var fitur = document.forms["form-group"]["fitur[]"];
if(fitur[0].checked == false && fitur[1].checked == false
&& fitur[2].checked == false){
alert("Please fill all the form");
return false;
}
}
function iphone(){
if(document.forms["form-group"]["merek"].value ==
"Iphone"){
document.getElementById("kondisi").innerHTML =
'<option>Baru</option>';
}
if(document.forms["form-group"]["merek"].value ==
"Samsung"){
document.getElementById("kondisi").innerHTML =
'<option>Baru</option><option>Bekas</option>';
}
if(document.forms["form-group"]["merek"].value == "Oppo"){
document.getElementById("kondisi").innerHTML =
'<option>Baru</option><option>Bekas</option>';
}
}
function harga(){
if(document.forms["form-group"]["kondisi"].value ==
"Bekas"){
document.getElementById("harga").setAtrribute("max",30
00000);
document.getElementById("maks").innerHTML = "Harga
maksimal Rp3.000.000";
}
}
</script>
</head>
<body>
<form id="form-group" onsubmit="return validateform()">
<table>
<tr>
<td>Nama</td>
<td>:</td>
<td>
<input id="nama" type="text" name="nama"
placeholder="Nama Smartphone">
</td>
</tr>
<tr>
<td>Merek</td>
<td>:</td>
<td>
<select id="merek" name="merek"
onchange="iphone()">
<option>--Pilih Merek</option>
<option>Samsung</option>
<option>Iphone</option>
<option>Oppo</option>
</select>
</td>
</tr>
<tr>
<td>Kondisi</td>
<td>:</td>
<td>
<select id="kondisi" name="kondisi"
onchange="harga()">
<option>Baru</option>
<option>Bekas</option>
</select>
</td>
</tr>
<tr>
<td>Fitur</td>
<td>:</td>
<td>
<input type="checkbox" name="fitur[]"> 4G<br>
<input type="checkbox" name="fitur[]"> Front
Camera<br>
<input type="checkbox" name="fitur[]"> GPS
Navigation
</td>
</tr>
<tr>
<td>Harga</td>
<td>:</td>
<td>
<input id="harga" type="number" name="harga">
<p id="maks"></p>
</td>
</tr>
</table>
<input type="submit" name="submit">
</form>
</body>
</html>

2.
*{
font-family: Arial;
font-size: 14px;
color: #504a0b;
}

table {
border: none;
}

table td{
padding: 10px;
vertical-align: top;
}

table tr:nth-child(odd){
background-color: #ffffc2;
}

You might also like