我正在尝试将表单放入表单中,这是我的代码:
<form action="info.php" method="post" id="test1">
<input type="hidden" name="name" value="test">
<a id="test" style="text-decoration:none;" onclick="document.getElementById('test1').submit();">
<!-- somestuff -->
<form action="insertCart.inc.php" method="POST" id="tset11">
<p class="card button"><button type="button" onclick="document.getElementById('test11').submit();" name="add-to-cart">Add to Cart</button></p>
</form>
</div>
</a>
</form>
我已经用onclick尝试了很多JavaScript,但是如果我单击from中的按钮,那么它将提交id为“ test1”的from。 有什么办法可以解决吗?
您不能将表单标签嵌套在另一个表单中。
您不能嵌套表格,这是无效的HTML。
However, what you can do is use the
form
attribute in your inputs to create the same effect.From https://stackoverflow.com/a/54901309/1600379: