When the page provides a check box, the "Select All" and "deselect All" (or "Uncheck All") buttons are generally available. So how do you do this with JavaScript code? Here's a thought: Using the button's OnClick event, invoking the JavaScript function, and taking the "Select All" and "deselect All" (or "uncheck all") actions based on the parameters passed in, here is the complete code, which is stored in an HTML file to run the demo:
<! DOCTYPE html>
<span style= "White-space:pre" ></span>function selectall (name,tagname,type,scope) */ var selectAll= function (Name,tagname,type,scope) {
<span style= "White-space:pre" ></span> /* Get all control collections by tag name ("Input") */ elements = document.getElementsByTagName (tagName); var len = Elements.length;for (var i = 0;i<len;i++) {
<span style= "White-space:pre" ></span>/* if the label type is <span style= "font-family:arial, Helvetica, Sans-serif ;" >checkbox and Mark Signature is </span><span style= "font-family:arial, Helvetica, Sans-serif;" >checkbox1,</span>
<span style= "font-family:arial, Helvetica, Sans-serif;" ><span style= "White-space:pre" ></span> determines how to operate </span><span style= "font-family According to the parameters passed in: Arial, Helvetica, Sans-serif; >*/</span><span style= "font-family:arial, Helvetica, Sans-serif;" ></span>if (elements[i].type==type&&elements[i].name==name&&scope== ' all ') {Elements[i]. Checked=true;} else if (elements[i].type==type&&elements[i].name==name&&scope== ' None ') {elements[i].checked= false;}}} </script>
JavaScript Getting Started note: The implementation of the Select all feature