PHP-Mengenal alat Input bag-4 (Checkbox)

Contoh penggunaan checkbox:
<html>
<head>
<title>Mengenal Input: Checkbox</title>
</head>
<body>
<form name="form1" method="get">
Pilih Vendor :
<label><input type="checkbox" name="chkAsus" value="Asus">Asus</label>
<label><input type="checkbox" name="chkAcer" value="Acer">Acer</label>
<label><input type="checkbox" name="chkAxioo" value="Axioo">Axioo</label>
<input type="submit" name="btnSubmit" value="Submit">
</form>
</body>
</html>

<?php
/*-------------------------------------------------
Hasil dari Inputan, Gunakan Fungsi IF
---------------------------------------------------*/  
if(isset($_GET['chkAsus'])){
    $chk .= $_GET['chkAsus'].", ";
}
if(isset($_GET['chkAcer'])){
    $chk .= $_GET['chkAcer'].", ";
}
if(isset($_GET['chkAxioo'])){
    $chk .= $_GET['chkAxioo'];
}

    echo "<hr>Vendor yang kamu pilih adalah <b>".$chk."</b>";
?>
Hasil:
Gambar : Inputan menggunakan Checkbox

0 comments:

Post a Comment

Alexa Rank's

Follow

Powered by Blogger.
Post Comment