-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckbox using Jquery
More file actions
60 lines (51 loc) · 2.68 KB
/
Checkbox using Jquery
File metadata and controls
60 lines (51 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
$(document).ready(function () {
// $('#CP_Main_gvPOItems input[type=checkbox]').change(function () {
// disableCheckbox();
// });
var checkedCount, checkboxCount, disableCheckBox = 0;
var text = $("#CP_Main_lblStatus").val().trim();
var text1 = $("#CP_Main_txtPONumber").val().trim();
var text2 = text1.substring(0, 2);
//var txt = $("#<%=lblStatus.ClientID%>")
// alert(text);
// alert(text1);
// alert(text2);
disableCheckbox = function () {
//checked check-boxes length
checkedCount = $('#CP_Main_gvPOItems input[type=checkbox]:checked').length;
//check-boxes length
checkboxCount = $('#CP_Main_gvPOItems input[type=checkbox]').length;
//if no check-box is selected then alert
// if (checkedCount == 0) {
// alert('No check-box is selected');
// }
//check for all disabled check-boxes
//var disableCheckBox = 0;
$('#CP_Main_gvPOItems input[type=checkbox]').each(function () {
if ($(this).is(':disabled')) {
disableCheckBox++;
}
});
//if all check-boxes are disabled then disable button
if (checkboxCount == disableCheckBox) {
$('#CP_Main_btnCancelItem').attr("disabled", "disabled"); //# is missing
}
}
$("#CP_Main_btnCancelItem").button().click(function () {
var checkedCount = $('#CP_Main_gvPOItems input[type=checkbox]:checked').length;
var isDisabled = $(checkedCount).is(':disabled');
// alert(isDisabled);
var status = false;
if (checkedCount == 0 && isDisabled) {
alert('No check-box is selected');
status = false;
}
else if (!isDisabled && checkedCount > 0) {
var r = confirm("Are you sure you want to cancel selected Record(s)?'");
if (r == true) {
status = true;
GetCheckedRows();
}
}
return status;
});