In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to achieve full selection, cancellation and cross-page saving of CHECKBOX". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to achieve full selection, cancellation and cross-page saving of CHECKBOX"!
The copy code is as follows:
$(document) .ready (function () {
/ * *
* Select all checkbox
, /
$(".checkall") .live ("click", function () {
If ($(this) .attr ("checked") = = "checked") {/ / if selected
CheckAll ()
} else {
UnCheckAll ()
}
UpdateHfValues ()
});
$(".checkone") .each (function () {
$(this) .live ("click", function () {
CheckOne ()
UpdateHfValues ()
});
});
Function UnCheckAll () {
/ / deselect all
$(".checkone") .each (function () {
$(this) .removeAttr ("checked")
});
}
Function CheckAll () {
/ / Select all
$(".checkone") .each (function () {
$(this) .attr ("checked", "checked")
});
}
Function CheckOne () {
/ / check whether to select all when clicking a single message
Var $length = $(".checkone") .length
Var $checklenght = $(".checkone: checked") .length
If ($length = = $checklenght) {
$(".checkall") .attr ("checked", "checked")
} else {
$(".checkall") .removeAttr ("checked")
}
}
Var arr = ("# hfDel") .val () .split (",")
$(".checkone") .each (function () {
Var I = 0
For (I = 0; I)
< arr.length; i++) { if (arr[i] == $(this).val()) { $(this).attr("checked", "checked"); } } }); var checkedNum = $(".checkone:checked").length; var allNum = $(".checkone").length; if (checkedNum == allNum) { $(".checkall").attr("checked", "checked"); } function UpdateHfValues() { var $checkOneLen = $(".checkone:checked").length; var $conVal = ""; $(".checkone:checked").each(function (i) { $conVal += $(this).val() + ","; }); if ($conVal.length >0) {
$conVal = $conVal.substring (0, $conVal.length-1)
}
$conVal = $conVal + "," + $("# hfDel"). Val ()
Var allArray = $conVal.split (, ")
$(".checkone") .each (function () {
If (typeof $(this) .attr ("checked")! = "undefined" & & $(this) .attr ("checked") = = "checked") {
Var I = 0
Var find = false
For (I = 0; I)
< allArray.length; i++) { if (allArray[i] == $(this).val()) { find = true; } } if (find == false) { allArray.push($(this).val()); } } else { var i = 0; for (i = 0; i < allArray.length; i++) { if (allArray[i] == $(this).val()) { allArray[i] = ""; } } } }); var i = 0; var result = ""; for (i = 0; i < allArray.length; i++) { if (allArray[i] != "") { result += allArray[i] + ","; } } if (result.length >0) {
Result = result.substring (0, result.length-1)
}
$("# hfDel") .val (result)
}
Function UpdateValues () {
Alert ($("# hfDel") .val ())
Var $checkOneLen = $(".checkone: checked") .length
Var $conVal = ""
$(".checkone: checked") .each (function (I) {
$conVal + = $(this). Val () + ","
});
$conVal = $conVal.substring (0, $conVal.length-1)
("# hfDel") .val ($conVal)
}
$("# btnDeletes"). Unbind ("click"). Live ("click", function () {
If ($("# hfDel") .val ()! = ") {
If (confirm ("are you sure you want to enable the selected option?") {
Return true
} else {
Return false
}
} else {
Alert ("you have not selected the option to enable!")
Return false
}
});
$("# lbTingYong"). Unbind ("click"). Live ("click", function () {
If ($("# hfDel") .val ()! = ") {
If (confirm ("are you sure you want to disable the selected option?") {
Return true
} else {
Return false
}
} else {
Alert ("you have not selected the option to deactivate!")
Return false
}
});
});
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.