【问题标题】:Html browser compatibility submit type inputhtml浏览器兼容性提交类型输入
【发布时间】:2014-05-24 02:08:05
【问题描述】:

我有以下代码:

<html>
<head>
    <title>Title</title>
</head>
<body>
<form name="select" id="selectForm" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
    <input type="checkbox" name="checkbox" form="selectForm" />CheckBox
</form>
<input type="submit" value="Submit" name="submit" form="selectForm" />
</body>
</html>

Chrome 和 FF 中的女巫会刷新页面,然后单击提交,但在 IE 11 中不会。在 IE 11 中,仅当提交按钮位于表单内时才有效。

你能帮我理解为什么吗?或者有没有办法让它与表单外的提交按钮一起工作?

【问题讨论】:

  • 为什么在表格之外需要它?
  • @YuriyGalanter : 因为我使用表格来定位页面中的元素,所以表格的一部分在表格行的顶部,而提交按钮在另一个表格行中要低得多跨度>

标签: html forms cross-browser


【解决方案1】:

如果您需要能够通过外部按钮普遍提交表单 - 只需定义一个普通按钮并在其 onclick 事件处理程序中执行 form.submit 例如

<form name="select" id="selectForm" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
    <input type="checkbox" name="checkbox" form="selectForm" />CheckBox
</form>

<input type="button" value="Submit" name="submit" onclick="document.getElementById('selectForm').submit();" />

【讨论】:

    猜你喜欢
    • 2014-06-15
    • 1970-01-01
    • 2014-09-11
    • 2011-04-29
    • 1970-01-01
    • 1970-01-01
    • 2018-11-25
    • 2012-10-19
    相关资源
    最近更新 更多