Below code is showing some data from database, here in each row there is a checkbox having name of primaryid from database ..and when user click less than then 5 checkboxes a alert appear as show all the code is working .but
Here I want that when user click 5 checkboxes i want the unique name of 5 checkboxes select and on submit button click and i want to do some php code with these 5 unique ids.
$sql="some sql";
$result = mysqli_query($mysql,$sql);
while($res1=mysqli_fetch_array($result,MYSQLI_ASSOC)) {
?>
<tr>
<td>
<input type="checkbox" name="studentid" value="<?php echo $res1['leadID']?>" ></td>
<td>some stuff here </td>
</tr>
<?php }
?>
<input type="submit" name="submit" value="Submit" class="btn newcol1" id="submit2" onClick="checkboxes();">
<script>
function checkboxes()
{
var inputElems = document.getElementsByTagName("input"),
count = 0;
for (var i=0; i<inputElems.length; i++) {
if (inputElems[i].type == "checkbox" && inputElems[i].checked == true){
count++;
}
}
if(count < 5){
alert ("Select at least 5 leads");
}
} </script>
Aucun commentaire:
Enregistrer un commentaire