我有一个带有两个提交按钮的表单。这不是问题;我可以做到这一点。我们切入追逐。这里的HTML:带有两个“提交”输入的HTML表单奇怪
<!-- Assume there's a lot more document here. -->
<form action="place1.html" method="GET">
<input type="submit" value="Go to Place 1!" />
<input type="submit" formaction="place2.html" value="Go to Place 2!" />
</form>
第一个按钮完全按预期工作。第二个按钮是奇怪的 - 它实际上是去place1.html,除非你点击最右边的十个左右的像素 - 然后它会去place2.html。有人知道这里发生了什么吗?我已经在Google Chrome和Internet Explorer上对它进行了测试。它是我的HTML吗?浏览器?我的电脑?
更新
好的,所以我禁用了页面上的CSS - 这没有什么区别。无论如何,没有任何类型的CSS定位输入。我还从form
标记中删除了action
属性,并按照Agony的建议(无骰子)为第一个提交按钮添加了formaction
属性。 (我会保留这个,因为它感觉更干净。)
这里有一点我的环境。我实际上有三个按钮包含在两个字段集包含在一个表单中。现在,它可能是CSS上的div。
<form id="server-form" method="post">
<input type="hidden" name="custID" value="@Model.CustomerID" form="server-form" />
<div style="float: left; width: 50%;">
<fieldset>
<legend>Fieldset One</legend>
<!-- Content goes here -->
<p><input type="submit" formaction="/page1.html" value="Go to Page 1" />
<input type="submit" formaction="/page2.html" value="Go to Page 2" /></p>
</fieldset>
</div>
<div style="float: right; width: 50%;">
<fieldset>
<legend>Fieldset Two</legend>
<!-- More and different content goes here -->
<p><input type="submit" formaction="/page3.html" value="Go to Page 3" /></p>
</fieldset>
</div>
为什么没有我之前透露的?我想保持的情况尽可能通用,看它是否缩小到我的具体实例之前,有任何愚蠢的事情,我只是失踪。
如果它有所作为,我也使用ASP.NET MVC 4与剃刀,但我不认为这应该。
当你说它的行为有所不同,取决于你点击的位置,我认为css。你能链接到任何现场展示这个问题吗? –
@erquhart不幸的是,没有;我拥有的例子都是在本地工作。 :(我会禁用CSS,看看有什么,但是。 –
@erquhart更新了这篇文章 - 里面有一些CSS,大多是浮动的。 –