首先给 table 加 id =tblfor(i=0;i<tbl.rows.length;i++){
  for(t=0;t<tbl.rows.(i).cells.length;t++)
   alert("这是第"+i+"行第"+t+"列的值"+tbl.rows(i).cells(t).innerHTML)}

解决方案 »

  1.   

    tableID.rows(i).cells(t)就是第i行,第j列的对象,比如,去最后一行的checkbox;tableID.firstChild.lastChild.lastChild.firstChild.value;
            |tbody      |最后以行 |最后一列 |里面的第一个对象--input有 dhtml 和 dom 两种方法 读取表格。前一种是dhtml ,后一种是 dom
      

  2.   

    <table id=t>
    ....
    <script>
    function getValue(oTable){
    var s=""
    for(i=0;i<oTable.rows.length;i++){
    for(j=0;j<oTable.rows[i].cells.length;j++){
    s+=oTable.rows[i].cells[j].firstChild.value+' '
    }
    s+='\n'
    }
    alert(s)
    }
    </script>
    <input type=button onclick="getValue(t)" value=get>
      

  3.   

    还可以dhtml dom结合起来使用。比如:tbl.rows(tbl.rows.length-1).lastChild.innerHTML;你可以尝试着用。不会的给我发短信!
      

  4.   

    如果我有某个下拉框中使用一事件,如onclick,此时怎么取到操作的是哪一行?
      

  5.   

    onclick="alert('第'+this.parentElement.parentElement.rowIndex+'行'"
      

  6.   

    为什么我查起来这么累呢?this.parentElement.parentElement后,没找到rowIndex。然后就不知道怎么找了。我用的是MSE,是不是其它工具比较好,还是我真的比较笨?
      

  7.   

    this是本对象
    this.parentElement返回所在的td
    this.parentElement.parentElement返回tr
    this.parentElement.parentElement.rowIndex返回该行的行标(从0开始)
      

  8.   

    顺便指出一点,fason 上面的 parentElement可以改为 parentNode,
    parentElement 用的是DHTML方法,parentNode/ 用的是dom 方法。两者可以结合起来适用。正如我上面讲的。this.parentNode.parentNode.rowIndex=this.parentElement.parentElement.rowIndex;
    你可以多看一些dhtml dom方面的资料就知道了。没什么难得。只是你现在还没有完全明白。等你理解之后就知道了!
      

  9.   

    如果你没有找到。可以一层一层的找
    alert(this.parentNode.tagName)
    alert(this.parentNode.parentNode.tagName);
    alert(this.parentNode.parentNode.parentNode.tagName);分别看每一层里面的东西就知道了!看看是什么元素!
      

  10.   

    我现在有多行,可以说都是cloneNode出来的,即table中的所有元素都是一样的,其中有checkbox.可是当调用moverow时,checkbox并不是原先所在行的值。
    怎么样使其保留原来的值呢?
    如二行为:
        <tr>
          <td width="10%">
            <input type="radio" name="radiobutton" value="1">
          </td>
          <td width="16%">
            <input name="datafield" size="8" value="test1">
          </td>
          <td width="11%">
            <input type="checkbox" name="show" value="checkbox" >
          </td>
          <td width="23%">
            <input type="checkbox" name="grouped" value="checkbox" checked>
          </td>
          <td width="40%" class="">
            <select name="aggregation">
    <option value="CountAggregation" selected >计数</option>        </select>
            <a onClick=AddResult(this.parentElement.parentElement.rowIndex) href="#">添加</a></td>
        </tr>    <tr>
          <td width="10%">
            <input type="radio" name="radiobutton" value="1">
          </td>
          <td width="16%">
            <input name="datafield" size="8" value="test2">
          </td>
          <td width="11%">
            <input type="checkbox" name="show" value="checkbox" >
          </td>
          <td width="23%">
            <input type="checkbox" name="grouped" value="checkbox" checked>
          </td>
          <td width="40%" class="">
            <select name="aggregation">
    <option value="SumAggregation" selected >汇总</option>
    <option value="CountAggregation" >计数</option>        </select>
            <a onClick=AddResult(this.parentElement.parentElement.rowIndex) href="#">添加</a></td>
        </tr>
    解决了这个问题,就结分了。
      

  11.   

    名字相同更好办啊,例如这样
    <form name=frm>
    <input name=txt><input name=txt onblur="alert(frm.txt[0].value+' '+frm.txt[1].value)">
    </form>
    名字相同访问时就当数组访问,你的先取得rowIndex,这样form1.username[rowIndex].value就可以了,当然,具体点是否对应(form1.username[rowIndex+1].value)
      

  12.   

    不是吧。我是说移动后,checkbox的值好像有时保留,可有时又没保留,怎样做到都保留呢?
    (保留用户操作后的内容)
    如用cloneNode,好像是初始值,并不是用户操作后的内容。