本帖最后由 index_jsf 于 2011-11-20 19:41:31 编辑

解决方案 »

  1.   

    var obj = docement.fom.elements;  这个写的什么语法 html元素的id不能重复,否则只有一个生效。
      

  2.   

    var obj = document.form.elements;应该是这样吧?
      

  3.   

    我写的  fom 就是form的id
      

  4.   

    var allCK=document.getElementsByName('delid'),checkedIDs=[],i=0;
    while(allCK[i++].checked)
       checkedIDs.push(allCK[i-1].value);var a=document.getElementById('delete');
    a.setAttribute("href","GoodsDelete.action?goodNum="+checkedIDs.join(','));
    a.click();
      

  5.   

    在复选框的 onchange 事件中,调用 JS 函数,判断是否选中,如选中,则去掉链接.
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>查看|</title>
    <script type="text/javascript">
    function ck(i){
    if(i==1){
    document.getElementById("myurl").innerHTML=""
    }
    }
    </script>
    </head><body>
    <div id="myurl">
    <a href="GoodsSelect.action?goodNum=${list.goodNum}">查看|</a>
    </div>
    <input type="checkbox" id="delck" value="0" onclick="ck(this.checked);">
    </body></html>
      

  6.   

    呃、、、好吧 我写的name,id 全是fom
      

  7.   

    jsp?你有form么?你看一看解析完的HTML源码?
      

  8.   

    我是新手,麻烦写点注释,对javascript不熟悉,谢谢
      

  9.   

    在foreach中ID会重复.document.getElementByID也不能工作!用class或扩展属性(像rel)用document.getElementsByTagName找input如果有指定的属性再判断.like thisfunction highlightRows(){ 
        if(!document.getElementsByTagName) return false;
        var tables=document.getElementsByTagName("table");
        for(var i=0;i<tables.length;i++){
                if(tables[i].getAttribute("rel")){
                        var rows=tables[i].getElementsByTagName("tr");
                        for(var j=0;j<rows.length;j++){
                                  var oldClassName=rows[j].className;
                                   rows[j].onmouseover=function(){this.className="currentrow";}
                                   rows[j].onmouseout=function(){this.className=(oldClassName=="")?"normalrow":oldClassName;}
                        }
                }else{continue;}
         }
    }
      

  10.   

    ///////////////////////////////////////////////////////----js方法
    function deleteAll(){
    var checkeds = document.fom.elements; 
    for(var i=1;i<=checkeds.length;i++){
    if(checkeds[i].checked==true)

    var b=document.getElementById("chuanzhi"+i/2).value;
    var a=document.getElementById('delete'+i/2);
    a.setAttribute("href","GoodsDelete.action?goodNum="+b);
    a.click();
    }
    }
    }
    //////////////////////////////////////////////////////////////js结束/////////////////////////////////////////////////////////////列表部分代码
    <%
                      int q =1;
                     %>
                     <c:forEach items="${gvList}" var="list" >
                      <tr bgcolor="#FFFFFF">
        <td height="20"><input type="checkbox" id = "ck" name="delid<%=q%>"/></td>
                        <td>${list.goodNum}</td>
    <td>${list.goodName}</td>
                        <td>${list.goodNums}</td>
                        <td>${list.good1}</td>
                        <td>
                         <a href="GoodsToUpdate.action?goodNum=${list.goodNum}">编辑|</a>
                         <a href="GoodsSelect.action?goodNum=${list.goodNum}">查看|</a>
                         <input type="hidden" id="chuanzhi<%=q%>"  value="${list.goodNum}"/>
    <a id="delete<%=q%>" href="GoodsDelete.action?goodNum=${list.goodNum}">删除</a>
    </td>
                      </tr>
                      <%q++;%>
                     </c:forEach>
    ///////////////////////////////////////////////////////////////结束
    实现一键删除功能
    调试完毕 贴上代码。。谢谢各位的帮助