代碼: javascript
<script type="text/javascript"> function delWork(id){ var boxes = document.getElementsByName("commonPage.idBox"); var selected = new Array(); for (var i=0; i<boxes.length; i++) { if(boxes[i].checked){ //push()把一個元素添加到數組的尾部 selected.push(boxes[i].value); } } // join()方法將數組中的全部元素轉換成字符串,而後鏈接起來,這恰好和String的split()方法是一個相反的操做。join()默認是使用「,」做爲分隔符,固然你也能夠在方法中指定分隔符 var idStr = selected.join(); if(idStr == ''){ www.jbxue.com alert('尚未選擇班次!'); return false; } if(confirm('肯定要刪除選中的記錄?')){ var url = '${webRoot}/base/marquee/work-delete.action?commonPage.idBox='+idStr; var myAjax = new Ajax.Request(url, {method:"post", onComplete:callback, asynchronous:true}); } } function callback(response){ alert(response.responseText); //var url = "${webRoot}/base/marquee/work-queryWorks.action"; var url = "${webRoot}/base/marquee/workQuery.action"; window.location.href = url; window.parent.document.getElementById("info").src = ""; } </script>