HTML 表单不适用于里面的表格

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15716376/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:01:10  来源:igfitidea点击:

HTML form is not working with table inside

htmlhtml-table

提问by Madhusudhan Dollu

Here I placed the tableinside formto arrange the form items.
It does not work even though it is valid.

在这里,我放在形式安排表单项。
即使它有效,它也不起作用。

<form method="get" action="another.php">
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td width="60%">
        Number: <input type="text" name="number" />
    </td>
    <td width="20%" align="center">
        Title: <input type="text" name="title" />
    </td>
    <td width="20%">
        Short Desc: <input type="text" name="shortdesc" />
    </td>
</tr>
</table>
</form>

When I press Enter, the form won't submit.
where as if I place a submit button anywhere inside the form, it works for both Enterkey and Button click.

当我按下 时Enter,表单不会提交。
就像我在表单内的任何地方放置一个提交按钮一样,它适用于Enter键和按钮单击。

<input type = "submit" value="Submit" />

But I don't want any buttons for submissions. I Submit the form by pressing Enterkey.
Any clues why this doesn't work ?

但我不想要任何提交按钮。我按Enter键提交表格。
任何线索为什么这不起作用?

采纳答案by Eli

Add this to your form

将此添加到您的表单中

<input type="submit" style="position: absolute; left: -9999px"/>

or

或者

<input type="submit" style="visibility: hidden;"/>

回答by thumber nirmal

add this ....will fix your problem for all three browser

添加这个......将解决所有三个浏览器的问题

 <input  type="submit" name="update" value=" Apply " 
style="position: absolute; height: 0px; width: 0px; border: none; padding: 0px;"
hidefocus="true" tabindex="-1"/>

回答by Michael Nguyen

all forms need a submit button to be submitted (without javascript atleast):

所有表单都需要提交一个提交按钮(至少没有 javascript):

you can make it invisible:

你可以让它不可见:

<input type="submit" style="visibility:hidden"/>