<html>
<head>
<meta http-equiv= "Content-type content=" html gb2312 "/>
<title>getelementsbyname example </title>
<script type=" Text/javascript ">
function test () {
//Get checkbox array
var elements = document.getelementsbyname ("role");
var str = "";
//Get the selected role
for (Var i=0;i<elements.length;i++) {
if (elements[i].checked) {
str + + > + elements[i] . Value + "n";
}
}
//Output
if (str = "") {
Alert ("You did not select any role!") ");
}
else{
Alert (Your selected role is: NN + str);
}
</script> </head>
<body>
<table cellspacing= "5" cellpadding= "2" align = "Center" border= "1" >
<tr>
<td align= "center" class= "Dgheader" nowrap> Select 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 <input name= "role" type= "checkbox" value= "Customer service personnel"
</td>
</tr>
<tr>
<td height= "colspan=" 2 "align= Center" >
<input type= "button" id= "Btnsubmit" style= "font-size:12px;width:90px" value= "Output selection Results" onclick= "Test ();"/>
</tr>
</table>
</body>
</html>