Recently, a small project in the company needs to do a multi-selection project's deletion function, so write the following JS script examples to implement, in fact, it is also a comparative thing that is often used, and the masters don't have to read.
code:
Function CA (FRM)
{
Var trk = 0;
For (VAR i = 0; i { Var e = frm.elements [i]; IF ((E.NAME! = 'allbox') && (e.type == ' Checkbox ') && (E.NAME! =' does not want to be selected Checkbox 's Name'))) { TRK ; E.CHECKED = frm.allbox.checked; FRM.DEL.DISABED = frm.allbox.checked? false: True; // Impact of the Disabled attribute of the delete button } } } Function CCA (FRM, CB) { VAR TB = to = 0; For (VAR i = 0; i { Var e = frm.elements [i]; IF ((E.NAME! = 'allbox') && (e.type == ' Checkbox ') && (E.NAME! =' does not want to be selected Checkbox 's Name'))) { TB ; IF (E.CHECKED) TO ; } } frm.allbox.checked = (to == TB)? TRUE: FALSE; IF (0 == to) // All unchecked and select some DISABLED attributes for delete buttons { frm.del.disabled = true; } Else { frm.del.disabled = false; } } -> script> Call method: The collective name is set to allbox, OnClick event executes CA (this.form); Choose Checbox Onclick event performs CCA (this.form, this);