- <c:forEach items="${menuList}" var="menuItem">
- <c:set value=",${menuItem.id }," var="id"/>
- <c:if test="${menuItem.parentId==0 }">
- <div class="sm-k" id="div${menuItem.id }">
- <div class="sm-k1">
- <div class="sm-k4a">
- <div class="sm-k4a1"><input name="menu" id="menu${menuItem.id }" type="checkbox" value="${menuItem.id }" <c:if test="${fn:contains(ids, id)}">checked</c:if> οnclick="subSelect('${menuItem.id}')"/></div>
- <div class="sm-k4a2"> ${menuItem.menuName }</div>
- </div>
- </div><br />
- <div class="sm-k4">
- <c:forEach items="${menuList}" var="subItem">
- <c:set value=",${subItem.id }," var="subId"/>
- <c:if test="${subItem.parentId==menuItem.id }">
- <div class="sm-k4a">
- <div class="sm-k4a1"><input name="subMenu" id="subMenu${subItem.id }" type="checkbox" value="${subItem.id }" <c:if test="${fn:contains(ids, subId)}">checked</c:if> οnclick="menuSelect('${subItem.id}','${menuItem.id }')"/></div>
- <div class="sm-k4a2"> ${subItem.menuName }</div>
- </div>
- </c:if>
- </c:forEach>
- </div>
- </div>
- </c:if>
- </c:forEach>
- function subSelect(id){
- if($('#menu'+id).is(':checked')){
- $('#div'+id+' input').each(function(){
- $(this).attr("checked","true");
- });
- }else{
- $('#div'+id+' input').each(function(){
- $(this).removeAttr("checked");
- });
- }
- }
- function menuSelect(id,menuId) {
- if($('#subMenu'+id).is(':checked')){
- $('#menu'+menuId).attr("checked","true");
- }else{
- var c = 0;
- $('#div'+menuId+' input[name="subMenu"]').each(function(){
- if($(this).attr("checked")=='checked'){
- c =1;
- }
- });
- if(c>0){
- $('#menu'+menuId).attr("checked","true");
- }else{
- $('#menu'+menuId).removeAttr("checked");
- }
- }
- }