当前位置:网站首页>4. The form with the input
4. The form with the input
2022-08-02 03:55:00 【Little Aning's cat】
htmlThe form with the input
看完本节,你将会了解到:①Understand the form、The difference between the list and form
②To master the form of the definition of various types of commonly used input method
③了解GET请求与POST 请求的区别,并可以使用GETRequests to transfer data to another page
1.什么是HTML表单
表单是一个包含表单元素的区域.
表单元素是允许用户在表单中输入内容,比如:文本域(textarea)、下拉列表、单选框(radio-buttons)、复选框(checkboxes)等等
比如:The search box is a form
2.Common form input element
①文本域(Text Fields)
文本域通过<input type="text">标签来设定,When need to type the letters in the form、数字等内容时,就会用到文本域.
②密码字段,用于输入密码
使用<input type="password">来定义
③单选按钮(Radio Buttons)
使用<input type="radio"> To define the form radio button
比如:选"是"“否”
④复选框
使用<input type="checkbox"> 定义复选框,In which the user can select one or more
④A drop-down list of radio
使用<select>定义一个下拉列表
与option连用
⑤提交按钮(Submit Button)<input type="submit"> 定义了提交按钮.
当用户单击确认按钮时,表单的内容会被传送到另一个文件.表单的动作属性定义了目的文件的文件名.由动作属性定义的这个文件通常会对接收到的输入数据进行相关的处理
3.GET与POST
(1)什么是 HTTP ?
超文本传输协议(HTTP)的设计目的是保证客户端与服务器之间的通信.
(2)两种 HTTP 请求方法:
GET 和 POST
GET - 从指定的资源请求数据.
POST - 向指定的资源提交要被处理的数据
(3)GET
GET 请求可被缓存
GET 请求保留在浏览器历史记录中
GET 请求可被收藏为书签
GET 请求不应在处理敏感数据时使用
GET 请求有长度限制
GET 请求只应当用于取回数据
(4)POST
POST 请求不会被缓存
POST 请求不会保留在浏览器历史记录中
POST 不能被收藏为书签
POST 请求对数据长度没有要求
4.演示代码
<!DOCTYPE html>
<html>
<head>
<title>
The form with the input
</title>
</head>
<body>
<h1>The form with the input</h1>
<form action = "1.html" method = "get"> <!-- 提交到1.html -->
<!-- Text field instance -->
姓名
<input type="text" name="name" ><br>
<!-- Password field instance -->
密码
<input type="password" name="password"><br>
<!-- Radio button instance -->
性别
<input type="radio" name="sex" value="男">男
<input type="radio" name="sex" value="女">女<br>
<!-- A drop-down list of radio instance -->
是否已婚
<select name="marryyyy">
<option value="">请选择</option>
<option value="已婚">已婚</option>
<option value="未婚">未婚</option>
</select><br>
<!-- Check box instance -->
兴趣爱好
<input type="checkbox" name="hobby1" value="唱歌">唱歌
<input type="checkbox" name="hobby2" value="画画">画画
<input type="checkbox" name="hobby3" value="游戏">游戏
<input type="checkbox" name="hobby4" value="运动">运动<br>
<!-- Submit button instance -->
<input type="submit" value="提交">
</form>
</body>
</html>
演示结果:











边栏推荐
- MySql高级 -- 约束
- Xiaoyao multi-open emulator ADB driver connection
- Solve the problem of uni - app packaged H5 website to download image
- 4.14到新公司的一天
- Phpstudy installs Thinkphp6 (problem + solution)
- PHP基金会三月新闻公告发布
- QR code generation API interface, which can be directly connected as an A tag
- 点名系统和数组元素为对象的排序求最大值和最小值
- 批量替换文件字体,简体-&gt;繁体
- ES6数组的扩展方法map、filter、reduce、fill和数组遍历for…in for…of arr.forEach
猜你喜欢
随机推荐
display,visibility,opacity
Solve the problem of uni - app packaged H5 website to download image
解决5+APP真机测试无法访问后台(同局域网)
4.14到新公司的一天
TCP communications program
每日五道面试题总结 22/7/23
v-on基本使用、参数传递、修饰词
js 中this指向
关于tp的apache 的.htaccess文件
PHP8.2 version release administrator and release plan
(1)Thinkphp6入门、安装视图、模板渲染、变量赋值
js 之 Object.defineProperty()
第一次手撕代码,如何解出全排列问题
PHP有哪些杀手级超厉害框架或库或应用?
PHP有哪些框架?
PHP图片压缩到指定的大小
clock tick marks
js 正则中 replace() 使用
[league/flysystem]一个优雅且支持度非常高的文件操作接口
[trendsoft/capital]金额转中文大写库








![[sebastian/diff]一个比较两段文本的历史变化扩展库](/img/c7/ea79db7a5003523ece7cf4f39e4987.png)
