一、
form表单标签语法
<form action="表单提交地址" method="提交方法">
...文本框、按钮等表单元素
</form>
看下生活案例用图:
表单图1
表单图2
生活当中表单使用案例
form表单属性说明
见下面链接:
http://www.runoob.com/tags/tag-form.html
其中重要的属性是 action 和 method 和 enctype
参数 | 值 | 说明 |
---|---|---|
action | 表单的提交地址 | |
method | get,post,delete,update | 向服务器的提交方式,get都是明文,post 一般参数会隐藏 |
enctype | 1.application/x-www-form-ur|encoded:默认的编码方式,将空件中的值 处理成URL编码方式。2、mutipart/form-data:以二进制流的方式来处理表单数据。3、text/plain:当表单的action属性值为mailto:URL的形式时使用 | 提交表单的编码方式 |
<form> 元素包含一个或多个如下的表单元素:
<input> 输入 按钮 文件上传 单选 多选 等等
<textarea> 输入框域 可以输入很多的文字
<button> 按钮
<select> 下拉选择
<option> 下拉选择选项
<optgroup> 分组
<fieldset> 属性值
<label> 文本
input标签常用type重点说明
单行文本:指定<input .../> type属性为 text 即可
密码输入框:指定<input .../> type属性为 password 即可
隐藏域:指定<input .../> type属性为 hidden 即可
单选框:指定<input .../> type属性为 radio 即可
复选框:指定<input .../> type属性为 checkbox 即可
上传文件:指定<input .../> type属性为 file 即可
提交、重置:指定<input .../> type属性为 submit、reset 或者普通按钮button即可
input标签中常用的属性
属性名 | 描述 |
---|---|
checked | 设置单选框初始状态是束处于选中状态,只有当type属性为checkbox或radio时才可指定 |
disabled | 设置首次加载时禁用此元素 type ="hidden" 时不能一该属性 |
maxlength | 该属性是一个数字,指定文框中所充许输入的最大字符数 |
readonly | 指定该文 本框内的值 不允许修改(可以使用javascript脚本修改) |
size | 该属性是一个数字,指定该元素的长度。当type="hidden"时不有指定该属性 |
src | 指定图像域所显示的图像URL,只有当type="image"时才可以指定该属性 |
HTTP请求详解:
http://www.cnblogs.com/li0803/archive/2008/11/03/1324746.html
input案例
<!DOCTYPE html>
<html>
<head>
<title>表单案例</title>
</head>
<body>
<h3>交友网站注册</h3>
email:<input type="text" name="email" >
<form action="success.html" method="post">
用户名:<input type="text" name="username"><br>
密码:<input type="password" name="password"><br>
确认密码:<input type="password" name="repassword"><br>
验证码:<input type="text" maxlength="6" name="verifycode"><br>
姓别:<input type="radio" name="sex" value="1"> 男
<input type="radio" name="sex" value="0"> 女
<input type="radio" name="sex" value="2"> 人妖
<input type="radio" name="sex" value="3"> 双性
<input type="radio" name="sex" value="4"> 保密<br>
爱好:<input type="checkbox" name="hobby" value="1"> 学习
<input type="checkbox" name="hobby" value="2"> 打王者
<input type="checkbox" name="hobby" value="3"> 睡觉
<input type="checkbox" name="hobby" value="4"> 吃饭
<input type="checkbox" name="hobby" value="5"> 做饭 <br>
个性签名:<input type="text" maxlength="30" name="signature"><br>
个人简介:<textarea rows="7" cols="60" name="resume">aabbccdd</textarea><br>
<input type="submit" name="submit" value=" 注册 "> <input type="reset" name="reset">
</form>
</body>
</html>
效果
09B2AB96-3B7C-437E-9660-6C32E61297A0.png