是否可以将 html 表单元素包装在多个表单标签中? [英] Is it possible to wrap html form elements in multiple form tags?

查看:26
本文介绍了是否可以将 html 表单元素包装在多个表单标签中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将表单的每个元素都包含在 HTML 页面中的 <form> 标签中会不会是错误的?很好奇为什么会出错:

基本上我必须介绍两种形式(form1form2),有些元素与第一种相关,而另一些则与第二种相关.布局必须完全基于表格,因为这两种形式的元素都在页面上,这是我写的(根据 中的这一输入:

tit<form action="x"><form action="x"><input type="submit" value="x"><!-- 正在提交..哪种表格...?--></表单></表单></body></html>

w3 验证器说:

<块引用>

Would it be wrong to have every element of a form wrapped in <form> tags in an HTML page? Am curious as to why it would be wrong:

Basically I have to introduce two forms(form1 and form2) and there are some elements associated with the first while others with the second.The layout has to be completely table based and since the elements of both forms are all over the page here is what i wrote(according to http://validator.w3.org/check, the code is valid):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
 <html>
<head>
   <title>Title of the document</title>
 </head>

 <body>
<table border="1">
    <tr>
        <td>
            <form name="form1" method="POST" action="via.php">
            Enter the first form text here!:    <input type="text" name="first"/>
            </form>
        </td>
        <td rowspan="2">
            <form name="form2" method="POST" action="via.php">
                Enter the second form text here!:<input type="text" name="second"/>
            </form>

            <form name="form1" method="POST" action="via.php">
            Enter the first form text here!:<input type="text" name="first"/>
            </form>
        </td>
  </tr>
  <tr>
        <td>
        <form name="form1" method="POST" action="via.php">
            <input type="submit" name="form1submit" value="submit1"/>
        </form>
        <form name="form12" method="POST" action="via.php">
            <input type="submit" name="form2submit" value="submit2"/>
        </form>
        </td>


  </tr>
</table>

解决方案

Nested forms are not allowed, according to the specification:

Given this input in the w3 validator:

<!DOCTYPE html><html><head><title>tit</title></head><body>
<form action="x">
    <form action="x">
        <input type="submit" value="x"> <!-- Submitting.. Which form...?-->
    </form>
</form>    
</body></html>

The w3 validator says:

这篇关于是否可以将 html 表单元素包装在多个表单标签中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆