javaweb—HTML表单
表单元素:
定义表单使用成对的<form>标记,表示要将此元素中所涵盖的控件中的数据传入到服务器
主要属性:
action:表单提交URL;method:数据提交方式;enctype:表单数据进行编码的方式
**表单控件:**由许多不同类型的控件,其是一种HTML元素,是信息输入项,包含
input元素(具有不同的外观):文本框,密码框,单选框,按钮…
其他元素:标签,文本域,下拉选
input元素
文本框 <input type = “text”/>
密码框:<input type = “password”/>
主要属性:value:由访问者自由输入任何文本
**Maxlength:**限制输入的字符数
**Readonly:**设置文本控件的只读
单选框: <input type =“radio”/>
复选框:<input type =“checkbox”/>
属性:value:文本,当提交form时,选中单选按钮,则发送服务器
Name:实现分组,一组单选框或者复选框名称必须相同
Check:设置选中
提交按钮:<input type = "submit " value=“提交”/>传送表单数据给服务器
重置按钮:<input type = “reset” value=“重置”/>清空内容,并 设为最初默认状态
普通按钮:<input type = “button” value=""/>执行客户端脚本
下拉选语法:<select>
<option></option>
</select>
<%-- Created by IntelliJ IDEA. User: 榕宝 Date: 2021/11/5 Time: 14:39 To change this template use File | Settings | File Templates. --%> <%@ page language= "java" contentType= "text/html; charset=UTF-8" pageEncoding= "UTF-8" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <head> <meta charset="UTF-8" > <title>石家庄铁道大学在校学生行程统计</title> </head> <body> <form action="back.jsp" method="post"> <table align="center" border="1" width="500"> <tr> <td>1.姓名: </td> <td> <label> <input type="text" name="name" /> </label> </td> </tr> <tr> <td>2.学号 </td> <td> <label> <input type="text" name="id" maxlength="8"/> </label> </td> </tr> <tr> <td>3.学生类别: </td> <td> <label> <input type="radio" name="leibie" value="本科生">本科生 <input type="radio" name="leibie" value="研究生" checked>研究生 </label> </td> </tr> <tr> <td>4.院系:</td> <td> <label> <select name="xueyuan"> <option value="土木学院">土木学院</option> <option value="机械学院">机械学院</option> <option value="交通学院">交通学院</option> <option value="信息学院" selected>信息学院</option> <option value="经管学院">经管学院</option> </select> </label> </td> </tr> <tr> <td>5.联系电话: </td> <td> <label> <input type="text" name="phone" maxlength="11"/> </label> </td> </tr> <tr> <td>6.健康码颜色: </td> <td> <label> <input type="radio" name="color" value="绿码">绿码 <input type="radio" name="color" value="黄码" checked>黄码 <input type="radio" name="color" value="红码">红码 </label> </td> </tr> <tr> <td>7.行程统计: </td> <td> <label> <input type="checkbox" name="xingcheng" value="10月30日去过人民医院" />10月30日去过人民医院 <input type="checkbox" name="xingcheng" value="10月25日以来去过深泽县人民医院" />10月25日以来去过深泽县人民医院 <input type="checkbox" name="xingcheng" value="10月16日以来去过深泽县庄泽村" />10月16日以来去过深泽县庄泽村 <input type="checkbox" name="xingcheng" value="10月29日以来去过黑龙江哈尔滨市或者黑河市" />10月29日以来去过黑龙江哈尔滨市或者黑河市 <input type="checkbox" name="xingcheng" value="10月18日以来途径贵州遵义市;北京丰台、昌平" />10月18日以来途径贵州遵义市;北京丰台、昌平 <input type="checkbox" name="xingcheng" value="10月17日以来到过湖南长沙;青海海东市" checked="checked"/>10月17日以来到过湖南长沙;青海海东市 </label> </td> </tr> <tr> <td>8.其他涉疫信息需要填报的 </td> <td> <label> <input type="text" name="qita" /> </label> </td> </tr> <tr align="center"> <td colspan="2"> <input type="submit" value="提交" /> <input type="reset" value="重置" /> </td> </tr> </table> </form> </body>