<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  <title>Kolej Vokasional Sepang - E-Vote</title>
<style>
  /* Base for label styling */
[type="checkbox"]:not(:checked),
[type="checkbox"]:checked {
  position: absolute;
  left: -9999px;
}
[type="checkbox"]:not(:checked) + label,
[type="checkbox"]:checked + label {
  position: relative;
  padding-left: 25px;
  cursor: pointer;
}

/* checkbox aspect */
[type="checkbox"]:not(:checked) + label:before,
[type="checkbox"]:checked + label:before {
  content: '';
  position: absolute;
  left:0; top: 2px;
  width: 27px; height: 27px;
  border: 1px solid #aaa;
  background: #f8f8f8;
  border-radius: 3px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.3)
}
/* checked mark aspect */
[type="checkbox"]:not(:checked) + label:after,
[type="checkbox"]:checked + label:after {
  content: 'X';
  position: absolute;
  top: 3px; left: 4px;
  font-size: 28px;
  line-height: 0.8;
  color: #09ad7e;
  transition: all .2s;
}
/* checked mark aspect changes */
[type="checkbox"]:not(:checked) + label:after {
  opacity: 0;
  transform: scale(0);
}
[type="checkbox"]:checked + label:after {
  opacity: 1;
  transform: scale(1);
}
/* disabled checkbox */
[type="checkbox"]:disabled:not(:checked) + label:before,
[type="checkbox"]:disabled:checked + label:before {
  box-shadow: none;
  border-color: #bbb;
  background-color: #ddd;
}
[type="checkbox"]:disabled:checked + label:after {
  color: #999;
}
[type="checkbox"]:disabled + label {
  color: #aaa;
}
/* accessibility */
[type="checkbox"]:checked:focus + label:before,
[type="checkbox"]:not(:checked):focus + label:before {
  border: 1px dotted blue;
}
</style>

  </head>
<body>
<div class="container">
    <nav class="navbar navbar-default">

    <h1>KOLEJ VOKASIONAL SEPANG - E-VOTING SYSTEM</h1>
    <ul class="nav navbar-nav">
      <li class="active"><a href="index.html">Home</a></li>
      <li><a href="#">Profile Calon</a></li>
      <li><a href="#">Carian</a></li>
      <li><a href="loginregister.html">Undi</a></li>
      <li><a href="keputusan.php">Keputusan</a></li>
      <li><a href="loginregister.html">Login</a></li>
    </ul>

  </nav>

  <?php   
include 'dbconn.php';

// Create connection

$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}


$sql = "SELECT * FROM tblcandidate";
$result = mysqli_query($conn, $sql);
$counter = 1; 
while($row = mysqli_fetch_assoc($result)) {

$counter = $counter+1;

?>
<form name="checkbox" action="undiantest1.php" method="post">
<?php
if($row[candPost] == "UMUM") {?>
              <div class="col-md-3">
                     <h4><?php echo $row[candName];?></h4>
                    <p><img src="/evote/img/img<?php echo "$counter";?>.jpg" alt="calon<?php echo "$counter";?>" style="width:200px;height:225px;"/></p>
                    
                     
     <input type="checkbox" id="test<?php echo "$counter";?>" name="check[]" value="calon<?php echo "$counter";?>"  onclick="chkChecks('check[]')">
                  <label for="test<?php echo "$counter";?>"><br><br>Undi saya</label>
                </p>
               
 </div>

        
 <?php
}
}
                                 
?> 

<p><input type="submit" class="btn btn-success" name="submit1" value="hantar undian anda"></p>
 
</form>


<script type="text/javascript">

function chkChecks(nme) {
var isChecked = 0;
var c = document.getElementsByName(nme);
for (var i = 0; i < c.length; i++) {
if (c[i].checked) {
isChecked ++;

if (isChecked >7) {  // maximum of seven checkboxes - change as required
alert ('ANDA HANYA BOLEH MENGUNDI TIDAK LEBIH DARI 7 CALON');
c[i].checked = false;
return false;
}
}
}
}

function showchoices(nme) {
var checkedVals = "";
var report = "SILA UNDI CALON PILIHAN ANDA";
var c = document.getElementsByName(nme);
for (var i = 0; i < c.length; i++) {
if (c[i].checked) {
checkedVals += c[i].value + " ";
}
}

if (checkedVals != "") {report = "You have selected " + checkedVals}
alert (report);
}

</script>


</div>
</body>
</html>
