Use jquery to get a background pass value to select all

Source: Internet
Author: User

Note: Funs is a list<function> from the action where the property has its sub-object list<role> traversed by the s tag, or through the C tag.

In the JSP page:

<s:iterator value= "funs" var= "Fun" >
<tr>
<td><!--A list of parent permissions--
<input type= "checkbox" Name= "Checkfuns"id= "Parent_${fun.fid}"Value= "${fun.fid}"/>${fun.fname}
</td>
<td><!--a list of the corresponding child permissions--
<s:iterator value= "#fun. Childfuns" var= "Childfun" >
<input type= "checkbox" Name= "Checkfuns"id= "Child_${fun.fid}_${childfun.fid}"Value= "${childfun.fid}"/>${childfun.fname}
</s:iterator>
</td>
</tr>
</s:iterator>

jquery in the wording:

$ (function () {
Select the parent permission, and the child permissions are selected
$ ("input[id^= ' Parent_ ']"). Click (function () {// red ^ represents start from Parent_
var id = $ (this). Val ();
$ ("input[id^= ' Child_" +id+ "_ ']"). Prop (' checked ',$ (this). Prop (' checked '));
});

If the number of child permissions is the same as the number of child permissions, the parent permission is also selected
});

Use jquery to get a background pass value to select all

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.