Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 带链接的可单击行_Php_Html - Fatal编程技术网

Php 带链接的可单击行

Php 带链接的可单击行,php,html,Php,Html,如何使每一行都可以单击而不重复 这是一个显示问题的示例,参数可能是代码: <table> <thead> <tr> <th>Code</th> <th>User</th> ... </tr> </thead> <tbody> <tr> <td><a href="

如何使每一行都可以单击而不重复 这是一个显示问题的示例,参数可能是代码:

<table>
<thead>
    <tr>
        <th>Code</th>
        <th>User</th>
        ...
    </tr>
</thead>
<tbody>
    <tr>
        <td><a href="page/123"> 123 </a></td>
        <td><a href="page/123"> User A </a></td>
        ...
    </tr>
    <tr>
        <td><a href="page/456"> 456 </a></td>
        <td><a href="page/456"> User B </a></td>
        ...
    </tr>
</tbody>

代码
使用者
...
...
...

谢谢
请原谅我的英语,我希望你能理解这个问题。

有几种不同的方法可以做到这一点。下面是两个使用普通javascript的示例和一个使用jQuery的示例

普通JS

对于纯javascript,只需使用onclick参数。非常直截了当

<table>
<thead>
    <tr>
        <th>Code</th>
        <th>User</th>
        ...
    </tr>
</thead>
<tbody>
    <tr onclick="window.location='page/parameter1';">
        <td> 123 </td>
        <td> User A </td>
        ...
    </tr>
    <tr onclick="window.location='page/parameter2';">
        <td> 456 </td>
        <td> User B </td>
        ...
    </tr>
</tbody>
</table>

您的代码应该如下所示:

<table>
<thead>
    <tr>
        <th>Code</th>
        <th>User</th>
        ...
    </tr>
</thead>
<tbody>
    <tr>
        <td><a href="page/parameter1"> 123 </a></td>
        <td><a href="page/parameter1"> User A </a></td>
        ...
    </tr>
    <tr>
        <td><a href="page/parameter2"> 456 </a></td>
        <td><a href="page/parameter2"> User B </a></td>
        ...
    </tr>
</tbody>

代码
使用者
...
...
...

在您的示例中添加了结束标记

什么是
参数1
参数2
?我不明白,您只是希望每个tr都是一个链接吗?可能重复:是!它起作用了!以前我发现了类似的解决方案,但没有效果,我不知道为什么=S谢谢!
<table>
<thead>
    <tr>
        <th>Code</th>
        <th>User</th>
        ...
    </tr>
</thead>
<tbody>
    <tr>
        <td><a href="page/parameter1"> 123 </a></td>
        <td><a href="page/parameter1"> User A </a></td>
        ...
    </tr>
    <tr>
        <td><a href="page/parameter2"> 456 </a></td>
        <td><a href="page/parameter2"> User B </a></td>
        ...
    </tr>
</tbody>