日期:2014-05-16  浏览次数:20385 次

js中的push和join方法

<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 == ''){
?????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>