我希望在点击特定行后获取特定行的内容并将其存储在会话中并发送到另一个php文件以进行进一步处理。
foreach ($employee as $key => $value) {
echo "
<tr>
<td >".$value->id."</td>
<td >".$value->name."</td>
</tr>
";
}
答案 0 :(得分:2)
检查此示例示例。希望它能帮助你前进。
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script type="text/javascript">
$( document ).ready(function() {
console.log( "ready!" );
$( ".tblRows" ).click(function() {
var row_data = $(this).attr("data");
alert(row_data);
});
});
</script>
</head>
<body>
<?php
$employee[] = array('id'=>'111', 'name'=>'Mango');
$employee[] = array('id'=>'222', 'name'=>'Apple');
echo '<table border=1>';
foreach ($employee as $key => $value) {
echo "<tr class='tblRows' data='".$value['id']."-".$value['name']."'>";
echo "<td>".$value['id']."</td>";
echo "<td>".$value['name']."</td>";
echo "</tr>";
}
echo '</table>';
?>
</body>
</html>