现在的HTML(DHTML)中,每个Tag都可以自定义属性。
也就是说,您可以定义:
<Table>
  <TR>  <!--第一行哟-->
    <TD><input type=text value='abc' Row=1 name=c1 onblur="..."></TD>
...onblur将在控件获取焦点(即用户点中的某个控件时)时触发。而属性Row则指示当前是在哪一行。 于是您可以在onblur中用c1.Row取得当前行数。
(明白了吗?)

解决方案 »

  1.   

    谢谢 Muf,这样也可以?那我真的不知道了,我试一下。还有,序号的问题呢?
      

  2.   

    Muf,好象不可以啊,属性如何自定义?去哪个地方定义
      

  3.   

    呵呵,很容易呀!把muf的修改一下即可!
    <script language="JAVASCRIPT">
    <!--
    function GetRow(var RowVal)
    {
    document.all.CurRow.value=RowVal;
    }
    //-->
    </script>......
    <input name="CurRow" type=hidden value="">
    ......
    <tr onclick="GetRow(id)">
    <TD>序号</TD>
    <TD>ID</TD>
    <TD>数据</TD>
    </tr>:)
    大意是这样的拉!
    用户点击表格的一行的时候激发click事件运行GetRow(id)记录此行的特征值。
    呵呵,真要实用的话,还要在每行的激发和失去焦点的时候置不同的颜色,删除
    行后提交表单从新刷新页面...
      

  4.   

    不知道可不可以这样?代码随手写的我没有测试环境,
    <script>
    var focusLine=-1;
    function setLine()
      for(i=0;i<event.srcElement.parentElement.parentElement.parentElement.children.length;i++){
      if(event.srcElement.parentElement.parentElement.parentElement.children[i]==event.srcElement.parentElement.parentElement){focusLine=i;break;}
      }
    }function delLine()
    {
      document.all.item("T1").children[0].children[focusLine].outerHTML="";
    }
    </script>
    <table id="T1">
      <tr>
       <td><input tppe=text onfocus="setLine();"></td><td><select onfocus="setLine();"><option>sssss</option></select></td>
      </tr>
      <tr>
       <td><input tppe=text onfocus="setLine();"></td><td><select onfocus="setLine();"><option>sssss</option></select></td>
      </tr>
    </table>
    <input type=button name="" onclick="delLine();">
      

  5.   

    给个实例吧<table width="100%" border="1" cellspacing="0" cellpadding="0" gcolor="#FFCC99" bordercolorlight="#FFFF99" bordercolordark="#993300">
      <tr bgcolor="#FFCCFF"> 
        <td>名称</td>
        <td>批号</td>
        <td>开始日期</td>
      </tr>
       
      <tr onclick="goto();"  mc=电源 totalnum=340  pihao=00001 onmouseover="javascript:event.srcElement.parentElement.style.cursor='hand'"> 
        <td>电源</td>
        <td>00001</td>
        <td>2001-5-23</td>
      </tr>
       
    </table><script language="javascript">
    var selectRow=null
    function goto(){
    if (event.srcElement.tagName=="TD");{
      //改变选中行的颜色
        if (selectRow!=null){
          selectRow.style.backgroundColor="#FFCC99";
          selectRow.style.color="black";
        }  
        event.srcElement.parentElement.style.backgroundColor ="#F9F7E8";
        event.srcElement.parentElement.style.color ="black";    
        
       //设置新的选中行到selectRow
        selectRow=event.srcElement.parentElement;
        
        //本例中是将选中行的属性pihao,totalnum,mc设置到一个FORM中并提交。
        //你可以进行其它的操作。
        gform.text2.value=selectRow.pihao
        gform.text3.value=selectRow.totalnum
        gform.mingcheng.value=selectRow.mc
        gform.submit()
        }  
        
    }</script>
      

  6.   

    Please use gobal array in this page ,and define the rowid for uself.
    If u input a form outside of ur table ,then u can use form.element[i]
    and easy conotrol where u are focus and what row u are delete