<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'mothod.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->  </head>
  
  <body>
  <div>税 收 计 划 情 况 表</div>
<form id="form_ndjh" name="form_ndjh" method="post" action="">
  <div id="divLen" style="display:block">
  <label>
<select name="nd" id="nd">
  <option>2010-11</option>
  <option value="2010-11">2010-11</option>
  <option value="2010-12">2010-12</option>
</select>
年度
  </label>
  <label>
 <select  name="lb" id = "lb">    
 <option value="0">税收计划</option>    
 <option value="1">税收任务完成</option>    
</select>   
  </label>
  </div><div id="div0" class="hiddiv" style="display:block" style="size:auto">
    <table id="table" width="100%" border="0" cellspacing="0" cellpadding="0" class="enregister_box">
  <tr>
<td width="179">税务机关</td>
<td width="46" align="center">一月</td>
<td width="46" align="center">二月</td>
<td width="46" align="center">三月</td>
<td width="46" align="center">四月</td>
<td width="46" align="center">五月</td>
<td width="46" align="center">六月</td>
<td width="46" align="center">七月</td>
<td width="46" align="center">八月</td>
<td width="46" align="center">九月</td>
<td width="46" align="center">十月</td>
<td width="88" align="center">十一月</td>
<td width="88" align="center">十二月</td>
  </tr></table>
</div>
<input type = "button" value="添加" onclick="AddRow2()"/><input type = "button" value="删除" onclick="DelRow2()"/>
<div align="center">
<input class="button" type="button" name="butSave" onclick="" value="保存"></input> 
</div>
</form>
</body>
</html>
<script>
   function AddRow2() {
        var tbl = document.getElementById("table");
        var rid = "row_"+tbl.rows.length;
        var row = tbl.insertRow(tbl.rows.length);

        var cell0 = row.insertCell(0);
        var cell1 = row.insertCell(1);
        var cell2 = row.insertCell(2);
        var cell3 = row.insertCell(3);
        var cell4 = row.insertCell(4);
        var cell5 = row.insertCell(5);
        var cell6 = row.insertCell(6);
var cell7 = row.insertCell(7);
        var cell8 = row.insertCell(8);
        var cell9 = row.insertCell(9);
        var cell10 = row.insertCell(10);
        var cell11 = row.insertCell(11);
        var cell12 = row.insertCell(12);
        var cell13 = row.insertCell(13); 
cell13.innerHTML = "<input type=\"checkbox\" id=\"" + "chk" + "_" + rid + "\"/>";
        cell0.innerHTML = "<input type=\"select\" id=\"" + "123" + "_" + rid + "\"/>";
        cell1.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "jhwc" + "\"/>"; 
        cell2.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "txt2" + "\"/>"; 
        cell3.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "txt3" + "\"/>"; 
        cell4.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "txt4" + "\"/>"; 
        cell5.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "txt5" + "\"/>"; 
cell6.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "txt6" + "\"/>"; 
        cell7.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "txt7" + "\"/>"; 
        cell8.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "txt8" + "\"/>"; 
        cell9.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "txt9" + "\"/>"; 
        cell10.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "txt10" + "\"/>"; 
cell11.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "txt11" + "\"/>"; 
        cell12.innerHTML = "<input type=\"text\" id=\"" + rid + "_" + "txt12" + "\"/>"; 
    }

   function DelRow2() {
        var tbl = document.getElementById("table");
        var length = tbl.rows.length;
        //alert(length);
        // 倒序遍历,这样才能顺利删除
        for (var i = length - 1; i >= 0; i--) {            //alert(table.rows[i].children(0).children(0));
            //var chk = table.childNodes(i).children(0).all[0];
            var chk = table.rows[i].cells[0].all[0];
            //alert(chk.id);
            if (chk.id.indexOf("chk") >= 0) {
                if (chk.checked) {
                    //alert(1);
                    //var rowIndex = table.rows[i].parentNode.parentNode.rowIndex;
                    tbl.deleteRow(i); 
                }
            }
        }
        
    }
</script>

解决方案 »

  1.   

    var frm = document.forms[0];
            for (var intCount = 0; intCount < frm.elements.length; intCount++) {
                var elem = frm.elements[intCount];
                if (elem.name != 'textbox') 
        {
                    return elem.value;
                }
            }
      

  2.   

    var chk = table.rows[i].cells[0].childNodes[0].firstChild
      

  3.   

    var v1="";
    var InputVal="";
    $(".enregister_box  > tr").find("input").each(function(){
         v1 = $(this).val();
        if(v1.length >0)
        {
           InputVal += v1;
        }
    })
      

  4.   

    看着有点蒙啊!有没有好的ssh + ext + dwr的框架呢?最好是有附带说明的!那叫一个急啊!