标签:
背景:SSH框架、页面采用dwz框架
需求:实现批量审批的功能
实现方法:带逗号拼接字符串传值
1.html 代码
1 <table class="table" width="100%" layoutH="112"> 2 <thead> 3 <tr> 4 <th width="40" align="center"><input type="checkbox" id="bll" onclick="toCheckAll(this.value)"/></th> 5 </tr> 6 </thead> 7 <tbody> 8 <s:iterator value="" status="" id="uid"> 9 <tr target="sid" id="${id}" align="center"> 10 <td><input type="checkbox" value="" id="cc" name="ibs"/> 11 </tr> 12 </s:iterator> 13 </tbody> 14 </table>
2.js代码
1 <script type="text/javascript"> 2 function toCheckAll(val){ 3 var hobbys = document.getElementsByName("ibs"); 4 5 var isAll = document.getElementById("bll"); 6 7 for(var i=0;i<hobbys.length;i++){ 8 hobbys[i].checked=isAll.checked; 9 10 } 11 } 12 13 function plspShow(){ 14 var id = $(‘input:checkbox:checked‘).attr("value"); 15 var arr = $(‘input:checkbox:checked‘); 16 17 if(arr.length==0){ 18 alertMsg.info("请选择一条记录"); 19 }else{ 20 var hobbys = document.getElementsByName("ibs"); 21 var bb=""; 22 var temp=""; 23 for(var i=0;i<hobbys.length;i++){ 24 if(hobbys[i].checked){ 25 temp=hobbys[i].value; 26 bb=bb+temp+","; 27 } 28 } 29 console.log(bb+"=="+bb.substring(0, bb.length-1)); 30 $.pdialog.open("bk_plbksh.action?id="+bb.substring(0, bb.length-1),"id","批量审批",{width:550,height:450,mask:true,maxable:false}); 31 } 32 } 33 </script>
3.Action 代码
1 public String plbksh() throws Exception{ 2 String[] fg = id.split(","); 3 for (int i = 0; i < fg.length; i++) { 4 bkobj = this.bkService.loadBkById(Long.valueOf(fg[i])); 5 } 6 return SUCCESS; 7 }
标签:
原文地址:http://www.cnblogs.com/xkl520xka/p/5626184.html