The document. getElementsByName (name) method is used to read the object array. The usage is as follows:
Var elements = document. getElementsByName ("role ");
("Role" is the name of each CheckBox in the CheckBox array)
For:
<Html> <pead> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312 "/> <title> getElementsByName example </title> </pead> <body> <table cellspacing =" 5 "cellpadding =" 2 "align =" Center "border = "1"> <tr> <td align = "center" class = "dgHeader" nowrap> select a role </td> <td align = "left"> System Administrator <input name = "role" type = "checkbox" value = "System Administrator"> General Manager <input name = "role" type = "checkbox" value = "General Manager"> agent <input name = "role" type = "checkbox" value = "agent"> customer service personnel <input name = "role" type = "checkbox" value = "Customer Service personnel"> </td> </tr> <td height = "29" colspan = "2" align = "center"> <input type = "button" id = "btnSubmit" style =" font-size: 12px; width: 90px; "value =" output selection result "onclick =" test (); "/> </tr> </table> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]