/**
* Select All Events
* @param an array of idlist storage IDs
* @param _this Object
* @param label to store IDs
*/
function SelectAll (Idlist,_this,label) {
var boxs = $ ("Input.select-single");//All Product records
is selected
if (_this.prop ("checked")) {
Boxs.prop ("Checked", true);//check box all selected
Boxs.each (function () {
if ($.inarray (), Val (), idlist) < 0) {//idlist does not contain the current ID value, add
Idlist.push ($ (this). Val ());
}
});
}else{
Cancel All
Boxs.prop ("Checked", false);//check box unchecked
Removes the current ID from the idlist array
Boxs.each (function () {
var index = $.inarray ($ (this). Val (), idlist);
if (index >= 0) {//idlist contains the current ID value, delete
Idlist.splice (index,1);
}
});
}
$ (label). Val (Idlist.join (","));//Writes the currently selected commodity primary key to the hidden domain gid
}
/***
* Radio Events
*/
function Selectsingle (Idlist,_this,label) {
if (_this.prop ("checked")) {//Radio selected
if ($.inarray (_this.val (), idlist) < 0) {//idlist does not contain the current ID value, add
Idlist.push (_this.val ());
}
if (_this.parents ("#list-table"). Find (". Select-single"). Length = = _this.parents ("#list-table"). Find (". Select-single:checked "). Length) {
When all check boxes are selected, the Select all check box is selected
_this.parents ("#list-table"). Find (". Select-all"). Prop ("checked", true);
}
}else{//The Radio check box unchecked
Removes the current ID from the idlist array
var index = $.inarray (_this.val (), idlist);
if (index >= 0) {//idlist contains the current ID value, delete
Idlist.splice (index,1);
}
_this.parents ("#list-table"). Find (". Select-all"). Prop ("checked", false);
}
$ (label). Val (Idlist.join (","));//Writes the currently selected commodity primary key to the hidden field ID
}
Select All Events
$ (". Select-all"). Click (function () {
var _this = $ (this);
SelectAll (Idlist,_this, ". Inner-section. List-title #ids");
});
//Radio Events
$ (". Select-single"). Click (function () {
var _this = $ (this);
Selectsingle (Idlist,_this, ". Inner-section. List-title #ids");
});
CheckBox selection and full selection in jquery