Showing posts with label checkbox. Show all posts
Showing posts with label checkbox. Show all posts

Friday, 18 May 2018

Multple checkbox selected or not

<script type="text/javascript" src='jquery.js'></script>
<script type="text/javascript">
$(document).ready(function() {
$('#extend_auto_expired').click(function(){
$("input[type=checkbox]:checked").each(function() {
alert( $(this).val() );
});
});
});
</script>
<center>
<form name='ck'>
<?php
for($r=0; $r<10;$r++){
echo "<input type='checkbox' name='t[]' value='$r'>$r<br>";
}
?>
<input type="button" id="extend_auto_expired" value="Extend auto expired" class="buttongreen" name="Submit">
</form>
<center>

Wednesday, 17 September 2014

How to get checked values in checkbox in dynamically by using jquery and javascript?

var chkArray = [];
$(".chk:checked").each(function() {
 chkArray.push($(this).val());
});
var selected;
selected = chkArray.join(',') + ",";
if(selected.length > 1){
 alert("You have selected " + selected); 
}else{
 alert("Please at least one of the checkbox"); 
}