Html 嵌套表单的解决方案
有没有办法创建嵌套表单 像这样Html 嵌套表单的解决方案,html,forms,nested-forms,Html,Forms,Nested Forms,有没有办法创建嵌套表单 像这样 <form action="" method="post"> <input type="text".... /> <input type="text".... /> <form action="some action"> <input type="submit" .... /> </form> </form> 如果没有,我如何在
<form action="" method="post">
<input type="text".... />
<input type="text".... />
<form action="some action">
<input type="submit" .... />
</form>
</form>
如果没有,我如何在没有嵌套表单的情况下获得相同的函数呢?不,您不能使用嵌套表单,但您的问题有一个简单的解决方案
<form action="" method="post">
<input type="submit" name="action" value="action1" />
<input type="submit" name="action" value="action2" />
</form>
ps:我看到您使用C#和.NET,这将被转换为:
public class ExampleController : Controller
{
....
[HttpPost]
public ActionResult Index(string action)
{
if (!string.IsNullOrEmpty(action) == "action1") {
// Do something
}
if (!string.IsNullOrEmpty(action) == "action2") {
// Do something
}
}
...
}
您希望通过嵌套表单实现什么?注意:对于HTML5,表单元素也可以位于
-元素之外,并使用。
public class ExampleController : Controller
{
....
[HttpPost]
public ActionResult Index(string action)
{
if (!string.IsNullOrEmpty(action) == "action1") {
// Do something
}
if (!string.IsNullOrEmpty(action) == "action2") {
// Do something
}
}
...
}