将按钮放在html表单之外

时间:2014-06-30 16:08:38

标签: php html html5 forms button

我一直无法让所有表单在提交时正确执行php。

我基本上有一个购物车,它将每件商品都添加到购物车

        $cartOutput .= "<tr>";
        $cartOutput .= "<td>" . $product_name . "</td>";
        $cartOutput .= "<td>$" . $price . "</td>";
        $cartOutput .= "<td>" . $case_weight . "</td>";
        $cartOutput .= "<td><form action='shop.php' method='post'>
        <input class='quantity' name='quantity[]' type='text' value='" . $each_item['quantity'] . "' size='1' maxlength='2'/>
        <input name='item_to_adjust[]' type='hidden' value='" . $item_id . "'</form></td>";
        $cartOutput .= "<td>$" . $priceTotal . "</td>";
        $cartOutput .= "<td><form action='retail_shop.php' method='post'><input name='deleteButton' type='image' value='' src='images/shop-x.gif' /><input name='index_to_remove' type='hidden' value='" . $i . "'/></form></td>";
        $cartOutput .= "</tr>";

我在其他地方有一个按钮可以发布到商店并执行php来更新数量等输入。它没有用,因为它无法访问&#34;表格。我看着这个并用html 5回答#2 Submit form using a button outside the <form> tag

似乎我可以使用按钮上的form="xx"来访问它。我生成了多个表单,他们现在没有ID,但如果我添加了ID,他们都需要是唯一的...它也说我不能在IE中执行此操作。

这是正确的方法吗?我是否可以从任何地方(甚至在表外)访问表单,只要它引用id?

0 个答案:

没有答案