CheckBox and <c:forEach> problem record in development

Source: Internet
Author: User

1.

$ ("[Type=checkbox]"). attr ("Checked", true); Online query is because the new version of jquery attr replaced with prop, according to this method changed, all OK.

2.

Do not know if you have encountered, not with struts2 development, natural can not use the STRUTS2 tag library.

If there is a need, go through 34 provinces and cities nationwide, and tick the provinces you have been to. So the effect is as follows:

If the provinces and cities are list<provinces> provinceslist, then uploading to the JSP page, we should certainly choose to use JSTL tags <c:forEach> traversal.

1 <C:foreachItems= "${provinceslist}"var= "Provinces">2         <inputtype= "checkbox"name= "PIDs"value= "${provinces.pid}"/>${provinces.name}3     </C:foreach>

If user Zhang San has been to Guangdong province and Jilin Province as above, then how to echo?

This is the time to use two <c:forEach> nesting:

1 <C:foreachItems= "${provinceslist}"var= "Provinces">2         <inputtype= "checkbox"name= "PIDs"value= "${provinces.pid}"3 <c:foreach Items= "${zsprovinces}"var= "Province">4                 <c:ifTest= "${province.pid = = provinces.pid}">5 checked= "Checked"6                 </c:if>7             </C:foreach>8 />${provinces.name}9 </C:foreach>

This whole me for a few hours, ashamed!!!

CheckBox and <c:forEach> problem record in development

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.