ajax 成功后动态加载 check 是否选中
后台json 数据回传
Map<String,List> mapUtils = new HashMap<String,List>();
前台js 动态加载 check 是否选中 function selectManager(){ var managerId =$("#managerId").val();$.ajax({ async:false, type: 'POST', url: '${pageContext.request.contextPath}/setting/selectManagerChange.action?t"=' +Math.random(), data: {"managerId":managerId}, dataType: 'json', success:function(data){ if(data!= null && data !=-1){ var groupList = data.staffGroupDetailList; var cbeGroup = 'cbxGroup'; var staffGroup = ''; $("input[name='selectValue']").each(function(index) { cbeGroup= 'cbxGroup' + index; $("#"+cbeGroup).attr("checked",false); }); var index =0; for(index = 0;index <groupList.length;index++){ staffGroup =groupList[index]; if(staffGroup.staff_id !='' && staffGroup.s_g_id == (index+1)){ cbeGroup= 'cbxGroup' + index; $("#"+cbeGroup).attr("checked",'checked'); } } } } }); }
页面代码 <s:iterator value="StaffGroupDetailList" status="record"> <tr id = "selectList"> <td style="width: 130px;"> ${s_g_name}</td> <td> <input id="cbxGroup<s:property value="#record.index"/>" name="selectValue" id="displayBox" style="width: 20px; vertical-align:-5px;" type="checkbox" ${(staff_id!=null)?'checked': ''} value="<s:property value="s_g_id"/>""> </td> </tr> </s:iterator> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |