当前位置:网站首页>Educoder Web练习题---表单的结构
Educoder Web练习题---表单的结构
2022-06-21 12:22:00 【是小鹿啊】
表单的结构
第1关 表单的基本概念
相关知识
表单的结构
表单是收集用户数据的容器。一个表单通常由表单控件和相关的提示信息组成。
- 表单控件:实现用户输入的组件。如文本框、密码框、单选按钮、复选按钮、下拉列表框、多行文本框、文件域等控件。
- 提示信息:提示用户进行填写和操作的说明文字。
每个表单都以form开始标签开始,以form结束标签结束。两个标签之间是组成表单的各个控件及提示信息。表单的基本结构如下:
<form action="url地址" method="提交方式" name="表单名称"> 各种表单控件及提示信息</form>
form的属性
表单在向服务器传输数据时需要一些进行一些设置,可通过form标签的属性来实现。
- name
每个表单及其表单控件都有一个 name 属性,用于在提交表单时对表单及数据进行识别。
- action
在提交表单时,action属性用于指定接收并处理表单数据的服务器程序的url地址。
- method
在提交表单时,method属性用于设置表单数据的提交方式。有两种方法:get方法和post方法。
get方法
采用GET方法时,浏览器会与服务器建立连接,然后将表单数据直接附在action属性设置的URL之后,通过URL在一个传输步骤中发送所有的表单数据,URL和表单数据之间用问号进行分隔。 显然这种方法用户数据要显示在地址栏中,保密性很差,而且对用户发送的数据量也有限制。
post方法
采用POST方法是在HTTP请求中嵌入表单数据。浏览器首先与action属性中指定的服务器建立连接,一旦建立连接之后,浏览器按分段传输的方法将数据发送给服务器。 显然这种方法用户数据嵌入在http请求中而不是地址栏的,保密性较好,对用户发送的数据量也无限制。但post方法发送的信息是未经加密的,容易被黑客获取。
- 其他属性
在HTML5中,form标签还有两个新的属性。
- autocomplete:规定是否启用表单的自动完成功能。自动完成允许浏览器侦测字段输入,当用户开始键入时,浏览器会基于以前键入过的值,自动列表显示在字段中填写的选项。取值为on,启用自动完成功能;取值为on,取值为off,禁止自动完成功能。
- novalidate:规定是否不进行表单验证。启用该属性,则当提交表单时不进行验证。
表单控件的类型
常用的表单控件有以下几种:
- input控件:是单行输入型控件,用来接受用户输入的信息。
- textarea控件:用来创建一个支持多行的文本输入区域。
- select控件:用于创建下拉列表框。
- button控件:用于定义一个按钮。
通关知识
1、下列选项中,不属于表单标记<form>的常用属性的是(D)。
A、action
B、method
C、name
D、size
2、在HTML中,<form method=””>,method属性表示(A)。
A、提交方式
B、表单所用的脚本语言
C、提交的URL地址
D、表单的类型
3、在HTML中,(C)标签用于在网页中创建表单。
A、<input>
B、<select>
C、<form>
D、<table>
4、在表单提交方式中,get方式的保密性好,并且无数据量的限制。(B)
A、正确
B、错误
5、在HTML中,要创建一个名为“myform”的表单,以get方式向服务器发送,表单提交后,执行程序的地址为passwodl.jsp,下面创建表单的代码中,正确的是(C)。
A、<form name="myform" method="get" submit="passwodl.jsp">...</form>
B、<form name="myform" method="get" submitsrc="passwodl.jsp">...</form>
C、<form name="myform" method="get" action="passwodl.jsp">...</form>
D、<form name="myform" method="post" action="passwodl.jsp">...</form>
第2关:学会设置action和method属性
相关知识
form表单示例
在HTML中,使用<form></form>标签来定义表单,在该标签中可通过name设置表单名称,通过action属性设置接收并处理表单数据的程序路径,method属性设置提交方法。
例如: <form name="myform" method="get" action="passwodl.jsp">...</form>
编程要求
根据提示,在右侧编辑器补充代码,在右侧编辑器中的Begin - End区域内补充代码,具体要求是:
- 创建一个带有下列选择的表单,表单名为"selectForm"
- 表单提交方式为post
- 表单提交后,执行程序"myselect.jsp"。
通关代码
<!DOCTYPE html>
<html>
<body>
<!-- ********* Begin ********* -->
<form name="selectForm" method="post" action="myselect.jsp">
<!-- ********* End ********* -->
<select size="1">
<option value="JZ">橘子</option>
<option value="PG">苹果</option>
<option value="XJ">香蕉</option>
</select>
</form>
</body>
</html>
边栏推荐
- Redis maximum memory elimination strategy
- [cloud native | Devops] Jenkins installation and actual combat (II)
- How does Huawei build a project centered project management system from 0 to 1?
- External attention tensorflow (under update)
- The wechat authorization login window will pop up automatically
- Nanjing University static program analyses -- Introduction learning notes
- channels详细使用说明
- Centos7 upgrade MySQL 5.6.40 to enterprise 5.6.49
- Tensorflower使用指定的GPU和GPU显存
- 2. 引用
猜你喜欢
![[cloud native | Devops] Jenkins installation and actual combat (II)](/img/1f/68ec217a920fb7c737227137e3243c.png)
[cloud native | Devops] Jenkins installation and actual combat (II)

Travel does not heal the soul

蜜雪冰城(已黑化)

【无标题】

Ansible operating instructions for configuring SSH authentication free for the first time

Technical scheme for environmental monitoring system of power distribution room

STM32 notes swj (jtag-dp and sw-dp)

These three young men are more ruthless than Ma Huateng and Zhang Yiming

The final battle of the giant: instant retailing

Methods commonly used in uniapp (part) - timestamp problem and rich text parsing image problem
随机推荐
[cloud native | Devops] Jenkins installation and actual combat (II)
Is pension insurance a financial product? What is the expected return?
智能辅助系统在配电室内的施工方案 安装位置
方法的繼承和重寫
STM32笔记之 SWJ(JTAG-DP和 SW-DP)
Nine trends and priorities that CIOs need to focus on in 2022
自动弹出 微信授权登录窗口
Subnet mask calculation
3. 运算符
8. 结构体
PWM (pulse width modulation) of STM32 notes
Inheritance and override of methods
【毕业季·进击的技术er】大学生涯的成长之路
findpanel的相关代码
程序三大结构-系统学习一
~~~~配置
蜜雪冰城(已黑化)
Ansible operating instructions for configuring SSH authentication free for the first time
1.内存分区模型
uniapp中常用到的方法(部分) - 时间戳问题及富文本解析图片问题