I want to do different action for each submit button. For example compare will go to "compare.php" and delete will go 开发者_开发百科to "test.php". I know i can't do form inside form but i can't separate to two forms because this is one table. I thought maybe to do
<?php if(isset($_POST["com"])){ javascript - link to compare.php}?>
but how can i send the _POST to this page? I also thought on send the ind as _GET but the user can select more then one (two deletes or two compares) of course if you have other solutions..
<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>
Thank you!
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.
精彩评论