【发布时间】:2010-12-28 00:03:53
【问题描述】:
我想为每个提交按钮执行不同的操作。例如,比较将转到“compare.php”,删除将转到“test.php”。我知道我不能在表格内做表格,但我不能分成两个表格,因为这是一张桌子。我想也许可以做
<?php if(isset($_POST["com"])){ javascript - link to compare.php}?>
但是我怎样才能将 _POST 发送到这个页面呢? 我还考虑将 ind 作为 _GET 发送,但用户可以选择多个(两个删除或两个比较) 当然,如果您有其他解决方案..
<html>
<head>
<script>
build ajax tbody...
for (i = 1; i <= numOfRows; i++)
{
oCell = oRow.insertCell(-1);
oCell.innerHTML = "<input type='checkbox' value='"+ ind + "'name='com[]'>";
oCell = oRow.insertCell(-1);
oCell.innerHTML = "<input type='checkbox' value='"+ ind + "'name='del[]' ;>";
.....
</script>
<body>
<form method="post" action="test.php">
<table>
<thead>
<tr>
<th><input type="submit" value="Compare" /></th>
<th><input type="submit" value="Delete" /></th>
</tr>
</thead>
<tbody></tdbody>
</table>
</form>
</body>
</html>
谢谢!
【问题讨论】: