表格>表格(ajax)>表格

时间:2010-12-27 16:00:56

标签: html ajax forms

我想为每个提交按钮执行不同的操作。例如,compare将转到“compare.php”,delete将转到“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>

谢谢!

1 个答案:

答案 0 :(得分:0)

你可以简单地拥有:

<input type="submit" value="Compare" onclick="this.form.action = 'someotherpage.php';" />

这将在单击提交按钮时更改表单操作。