Code
1 /*
2. the dojo framework must be introduced.
3. It is usually applicable to all or reselect operations in a container.
4. Check whether selected
5 Author: rnn
6 */
7 dojo. Declare (
"Checkboxclass ",
Null,
{
Container: "tableid",/* container ID */
Checkboxes: NULL,/* set of all check boxes, equivalent to a nodelist */
Count: 0,/* Number of current check boxes */
Selectedcount: 0,/* Number of selected check boxes that are currently easy to use */
Buttontype: 1,/* select the button type of the check box. 1 indicates itself is in the container. 2 indicates outside the container */
Constructor: function (container, buttontype ){
This. Container = container;
This. buttontype = buttontype;
This. checkboxes = dojo. Filter (Dojo. Query ("input", dojo. byid (this. Container), function (item ){
Return item. type = "checkbox ";
});
This. Count = This. checkboxes. Length-1;
VaR Index = 0;
VaR currentindex = 1;
If (this. buttontype = 2 ){
This. Count = This. Count + 1;
Currentindex = 0;
}
Dojo. foreach (this. checkboxes, function (item ){
If (index> = currentindex ){
Dojo. Connect (item, "click", itemcheckboxclick );
}
Index ++;
});
},/* Constructor, initialize some data */
Select: function (buttonid ){
VaR ischecked = dojo. byid (buttonid). checked;
If (ischecked ){
Dojo. foreach (this. checkboxes, function (item ){
Item. Checked = true;
});
This. selectedcount = This. count;
}
Else {
Dojo. foreach (this. checkboxes, function (item ){
Item. Checked = false;
});
This. selectedcount = 0;
}
},/* Select all events */
Checkselectedcount: function (){
If (this. selectedcount <= 0 ){
Alert ("no data selected ");
Return false;
}
Return true;
},
Setselectcount: function (type ){
If (type = 1 ){
This. selectedcount = This. selectedcount + 1;
}
Else {
This. selectedcount = This. selectedcount-1;
}
}
}
);