<table>
<tr id=t1 onclick="alert(document.all.t1.id)"><td>...</td></tr>
</table>

解决方案 »

  1.   

    java 与 javascript是不同地
      

  2.   

    把每个表格的第一个"列"里设置标签属性
    分别为id="1",,,,,,id="1000000000000"
    然后用上面的说发就可以了
      

  3.   

    需要 javascript 与jsp 相互配合使用! 我给你写了一个代码片段,只提供思路上的参考!<script language="javascript">
       function selecteRow(rowi){
         var url = "showinfo.jsp?rowID=" + rowi;
         document.location.href = url;   }
    </script>
    <%
      if(request.getParameter("rowID")!=null){
         ...
         ...
         ...
         ResultSet rs_info = Statement.executeQuery("select id,name,age from userinfo where id=" + request.getParameter("rowID"));
      }else{
         ResultSet rs_info = Statement.executeQuery("select id,name,age from userinfo");
     }
    %>
         <table border='1' width='100%'>
        
    <%    
       while(rs_info.next())
       {
     %>
       <tr onclick='javascript:selecteRow(<%=rs_info.getString(id)%>)'>        
          <td width='30%'><%=rs_info.getString("id")%></td>
          <td width='30%'><%=rs_info.getString("name")%></td>
          <td width='40%'><%=rs_info.getString("age")%></td>
       </tr>
    <%     
        }
    %>
    </table>
      

  4.   

    两种方法:一种是通过设置TR 的 ID来确定每一行
              另一种方法是通过TR 的属性sectionRowIndex得到当前行
      

  5.   

    x_coolboy(耍酷的猪) 老兄,给我一个通过TR 的属性sectionRowIndex得到当前行的方法的代码,我怎么只能得到第一行的为0,以后的行都得不到
      

  6.   

    我怎么在我上面的添加行的代码中加如onclick动作
      

  7.   

    兄弟,接着:
    给你一个微软的htc模型1、建一个CSS:
    .clsQueryDetail {
     font-size: 12px; color: #333366;  BEHAVIOR: url(../css_js/DynamicQuery.htc); 
    }2、在你的TD上,(注意是TD,上张帖子我打错了)都加入这个CSS
    <td width=20% valign=top class='clsQueryDetail'>
      

  8.   

    3、建DynamicQuery.htc
    <PUBLIC:COMPONENT>
    <PUBLIC:ATTACH EVENT="onmousedown"      ONEVENT="fnGrab()"   />
    <SCRIPT LANGUAGE="JScript">
      var now_tr=0;
      function fnGrab(){
        var oEl = event.srcElement;
        if (oEl.className == "clsQueryDetail"){
          window.document.attachEvent( "onmousedown"    , fnDynamicQuery );
          window.document.attachEvent( "onmouseup"    , fnRelease );
        }
      }
      
      function fnRelease(){
        var oEl=event.srcElement;
        window.document.detachEvent( "onmousedown" , fnDynamicQuery );
        window.document.detachEvent( "onmouseup" , fnRelease );
      }
      
      function fnDynamicQuery(){
        var oEl=event.srcElement;
        now_tr=oEl.parentElement.sectionRowIndex;
        alert("当前行是==========="+now_tr);
        /**
         *执行你的操作
        **/
        fnRelease();
      }
      

  9.   

    </SCRIPT>
    </PUBLIC:COMPONENT>