Automatically tick the value of a radio box or check box in a JSP

Source: Internet
Author: User

<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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.