ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
# 表单 # 表单 HTML 表单用于搜集不同类型的用户输入 - - - - - - 基本结构 ``` <form action="form_action.asp" metho="get" enctype="text/plain"> <p>First name: <input type="text" name="fname" /></p> <p>Last name: <input type="text" name="lname" /></p> <input type="submit" value="Submit" /> </form> ``` 属性值描述actionURL规定当提交表单时向何处发送表单数据。enctype见说明规定在发送表单数据之前如何对其进行编码。methodget post规定用于发送 form-data 的 HTTP 方法。name*form\_name*规定表单的名称。注意 必需的 **action** 属性规定当提交表单时,向何处发送表单数据。 **enctype** 值描述application/x-www-form-urlencoded在发送前编码所有字符(默认)multipart/form-data不对字符编码。在使用包含文件上传控件的表单时,必须使用该值。text/plain空格转换为 "+" 加号,但不对特殊字符编码。\*\* input type\*\* \> button \> checkbox \> file \> hidden \> image \> password \> radio \> reset \> submit \> text # 示例 get post 的不同 ![](https://box.kancloud.cn/6f33abd799260540860b9b27af2b42de_673x484.png) ``` <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>表单</title> </head> <body> <form action="#" method="get" accept-charset="utf-8"> 学号 <input type="text" name="num-g" /><br/><br/> 姓名 <input type="text" name="name-g" /><br/><br/> 班级 <input type="text" name="classs-g" /><br/><br/> <input type="submit" value="提交啦-get" /> </form> <form action="#" method="post" accept-charset="utf-8"> 学号 <input type="text" name="num-p" /><br/><br/> 姓名 <input type="text" name="name-p" /><br/><br/> 班级 <input type="text" name="classs-p" /><br/><br/> <input type="submit" value="提交啦-post" /> </form> </body> </html> ``` ## get ![](https://box.kancloud.cn/3d271948c1ea752b7088a248c09ffc42_877x348.png) ## post ![](https://box.kancloud.cn/7b791cbfe2db49dc99026cbfa469d8fa_749x441.png)