<div class="codetitle"> <span><a style="CURSOR: pointer" data="67362" class="copybut" id="copybut67362" onclick="doCopy('code67362')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code67362"> <br><script type="text/javascript"> <BR>function Workfunction (id){ <BR>var boxes = document.getElementsByName("commonPage.idBox"); <BR>var selected = new Array(); <BR>for (var i=0; i<boxes.length; i ) { <BR>if(boxes[i].checked){ <BR>//push()把一個元素加到數組的尾部<BR>selected.push(boxes[i].value); <BR>} <BR>} <BR>// join()方法將陣列中的所有元素轉換成字串,然後連接起來,這剛好和String的split()方法是一個相反的運算。 join()預設是使用「,」作為分隔符,當然你也可以在方法中指定分隔符號<BR>var idStr = selected.join(); <BR>if(idStr == ''){ <BR> alert('還沒選班次!'); <BR>return false; <BR>} <br><br>if(confirm('確定要刪除選取的記錄?')){ <br><br>var url = '${webRoot}/base/marquee/work-delete.action?commonPage.idBox=' idStr; <BR>var myAjax = new Ajax.Request(url, {method:"post", onComplete:callback, asynchronous :true}); <br><br>} <BR>} <br><br>function callback(response){ <BR>alert(response.responseText); <BR>//var url = "${webRoot = "${webRoot }/base/marquee/work-queryWorks.action"; <BR>var url = "${webRoot}/base/marquee/workQuery.action"; <BR>window.location.href = url; <br><br>window.parent.document.getElementById("info").src = ""; <BR>} <br><br></script> <br> </div>