Using JQUERY to select all and cancel all is not as complicated as js and supports more browsers.
Copy codeThe Code is as follows:
<Mce: script type = "text/javascript"> <! --
$ (Function (){
$ ("# Checkall"). click (function (){
$ ("Input [@ name = 'checkname [] ']"). each (function (){
$ (This). attr ("checked", true );
});
});
$ ("# Delcheckall"). click (function (){
$ ("Input [@ name = 'checkname [] ']"). each (function (){
$ (This). attr ("checked", false );
});
});
});
// --> </Mce: script>
<Input type = 'checkbox' id = 'id1' name = 'checkname [] 'value = '1'/> value1
<Input type = 'checkbox' id = 'id2' name = 'checkname [] 'value = '2'/> value2
<Input type = 'checkbox' id = 'id3 'name = 'checkname [] 'value = '3'/> value3
<Input type = "button" id = "checkall" name = "checkall" value = "select all"/>
<Input type = "button" id = "delcheckall" name = "delcheckall" value = "cancel all"/>
A simpler one:
Copy codeThe Code is as follows:
$ ("# Checkall"). click (
Function (){
If (this. checked ){
$ ("Input [name = 'checkname']"). attr ('checked', true)
} Else {
$ ("Input [name = 'checkname']"). attr ('checked', false)
}
}
);