1

我在一个复杂的页面上有多个表单,其中的字段由相当多的中间 HTML 分隔。在 Firefox 和 chrome 中,我可以声明一个表单并关闭它,然后在要与表单关联的字段中放置一个 form="xxx" 属性。这在 IE9 中似乎不起作用。

这是一个简化的示例:

    <?php
if (isset($_POST["field1"])) echo "Field1: " . $_POST["field1"] . "<br>";
if (isset($_POST["Btn1"])) echo "Btn1: " . $_POST["Btn1"] . "<br>";
if (isset($_POST["Btn2"])) echo "Btn2: " . $_POST["Btn2"] . "<br>";
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Test Page</title>
    <link rel="stylesheet" href="css/normalize.css" media="all">
    <!--[if lt IE 9]>
      <script src="js/html5shiv-printshiv.js" media="all"></script>
    <![endif]-->
  </head>
  <body>
    <form id="form1" action="Test.php" method="POST"></form>
    <input type="text" form="form1" id="field1" name="field1" value="text input">
    <button type="submit" form="form1" id="Btn1" name="Btn1" value="Btn1" title="Btn1">
      Btn1</button>
    <input type="submit" form="form1" id="Btn2" name="Btn2" value="Btn2" title="Btn2">
  </body>
</html>

我尝试添加 < meta http-equiv="X-UA-Compatible" content="IE=9" > ... 没有变化。

...其他人遇到此“功能”,我该如何解决?

4

3 回答 3

3

There does not seem to be any information about support to the form attribute in Microsoft’s info on support to HTML5 forms. A quick test suggests that even IE 10 does not support it.

So consider simplifying the structure. Intervening HTML should not be a problem, as long as your are not trying to overlap or nest forms.

于 2013-03-25T20:24:08.217 回答
0

form属性是 HTML5 添加的。它不适用于太旧而无法支持 HTML5 的浏览器。

于 2013-03-25T19:02:34.757 回答
-1

您需要在字段之后关闭表单标签,它应该如下所示:

<form id="form1" action="Test.php" method="POST">
    <input type="text" form="form1" id="field1" name="field1" value="text input">
    <button type="submit" form="form1" id="Btn1" name="Btn1" value="Btn1" title="Btn1">
      Btn1</button>
    <input type="submit" form="form1" id="Btn2" name="Btn2" value="Btn2" title="Btn2">
</form>

还为每个字段添加标签以使表单可访问。

于 2013-10-24T13:47:06.557 回答