<table>
<tr>
<TD class= "Tableleft" > Status </td>
<td><input type= "Radio" name= "U.state" value= "0" > Enabled
<input type= "Radio" name= "U.state" value= "1" > Disabled
</td>
</tr>
<tr>
<TD class= "Tableleft" > Roles </td>
<td><input type= "checkbox" Name= "U.roles" value= "Payment interface"/> Payment interface
<input type= "checkbox" Name= "U.roles" value= "query own customer"/> Query own customer
<input type= "checkbox" Name= "U.roles" value= "send message to Customer"/> Send message to Customer
<input type= "checkbox" Name= "U.roles" value= "open public"/> Open public number
<input type= "checkbox" Name= "U.roles" value= "build website"/> Website
</td>
</tr>
<script language= "JavaScript" >
$ ("Input:radio[value=${u.state}]"). attr (' checked ', true);//Let the radio box automatically tick based on the value of the alignment
$ (' input[type= ' checkbox "] '). each (function () {
var struids= "${u.roles}"; Background Access Data alert (struids);
if (struids!= ') {
var str=struids.split (","); To convert a string to an array with a comma, it is worth noting that split (",") is a comma plus a space
for (Var j=0;j<str.length;j++) {
$ (": Checkbox[value= '" "+str[j]+" '] "). attr (" Checked ", true);
}
}
});
</script>
</table>
Automatically tick the value of a radio box or check box in a JSP