我想为每个提交按钮做不同的操作。例如,compare将转到“compare.php”,而DELETE将转到“test.php”。我知道我不能在表单中做表单,但是我无法将两个表单分开,因为这是一个表。我想也许可以这样做:
<?php if(isset($_POST["com"])){ javascript - link to compare.php}?>
但是我怎样才能把_POST发送到这个页面呢?我也考虑过发送ind as_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>
谢谢!
You can simply have:
<input type="submit" value="Compare" onclick="this.form.action = 'someotherpage.php';" />
This will change the form action upon clicking the submit button.