日期:2014-05-19  浏览次数:20453 次

怎么样能实现鼠标单击取到table中的某行ID?
如下代码:从数据库中提出数据填充到table中,但是现在有一个问题:怎么样能取到某行的ID?

  <table   border=1   width= "1200 ">
    <tr> <td> &ETH;ò&ordm;&Aring; </td> <td> &Eacute;è±&cedil;×&acute;&Igrave;&not; </td> <td> &micro;&Ccedil;&frac14;&Ccedil;±í±à&ordm;&Aring; </td> <td> &Eacute;è±&cedil;&sup2;ú&Egrave;¨&micro;&yen;&Icirc;&raquo; </td> <td> &Eacute;è±&cedil;&Agrave;à±&eth; </td> <td> &Eacute;è±&cedil;&Atilde;&ucirc;&sup3;&AElig; </td> <td> ×&cent;&sup2;á&micro;&Ccedil;&frac14;&Ccedil;&raquo;ú&sup1;&sup1; </td> <td> ×&cent;&sup2;á&micro;&Ccedil;&frac14;&Ccedil;&Egrave;&Otilde;&AElig;&Uacute; </td> <td> &Eacute;è±&cedil;×&cent;&sup2;á&acute;ú&Acirc;&euml; </td> <td> ×&cent;&sup2;á&micro;&Ccedil;&frac14;&Ccedil;&Egrave;&Euml;&Ocirc;± </td> <td> &cedil;ü&ETH;&Acirc;&Egrave;&Otilde;&AElig;&Uacute; </td> <td> &micro;&yen;&Icirc;&raquo;&Auml;&Uacute;&sup2;&iquest;±à&ordm;&Aring; </td> <td> &sup3;§&sup3;&micro;&Aring;&AElig;&Otilde;&Otilde;±à&ordm;&Aring; </td> <td> &sup3;§&sup3;&micro;&Aring;&AElig;&Otilde;&Otilde;±à&ordm;&Aring; </td> <td> &sup3;§&sup3;&micro;&Aring;&AElig;&Otilde;&Otilde;±à&ordm;&Aring; </td> </tr>
    <?
    //&Ntilde;&shy;&raquo;·
    for($i=0;$i <$ar;$i++)
    {
    echo   " <tr> "   ;
    echo " <td> ";
    echo   mysql_result($rst1,$i, 'id ');
    echo " </td> ";
        echo " <td> ";
    echo   mysql_result($rst1,$i, 'bt ');
    echo " </td> ";
        echo " <td> ";
    echo   mysql_result($rst1,$i, 'fbsj ');
    echo " </td> ";
    ?>

</tr>
<?}?>
</table>

------解决方案--------------------
可以加一个input,类型为hidden
------解决方案--------------------
用js取得table的某一行,再得到某个单元格中的内容
------解决方案--------------------
table加个runat= "server " 和 ID
this.Table1.Rows[0].Cells[1] 代表第1行第二个td
------解决方案--------------------
<html>
<head>
<script language = "javascript ">
function aa()
{
for(i=0;i <document.f1.cb.length;i++)
{
if(document.f1.cb[i].checked == true)
{
alert(document.f1.cb[i].parentElement.parentElement.parentElement.rows(i).innerText);
var a = document.f1.cb[i].parentElement.parentElement.parentElement.rows(i).cells.length;
alert(a);
}
}
}
</script>
</head>
<body>
<form name = "f1 ">
<table name = "a ">
<tr>
<td> <input type = "checkbox " name = c