您的位置:首页 > Web前端 > HTML

HTML学习之表单

2014-09-09 20:59 183 查看
HTML表单

表单是HTML的一个重要部分,主要用于采集和提交用户输入的信息。

<form   name=“f1”     action=“处理表单用的URL”       method=“get或post” >

</form>

  1、name:   设置表单的名称。

  2、action:  设置表单的处理程序的URL。

  3、method:提交表单的方法。

HTML    表单中常用的标记:

输入域<input>一般在表单中使用

1、<inputtype=“text” />输入单行文字

2、<inputtype=“password”/>输入密码

3、<inputtype=“radio” />单选按钮

4、<inputtype=“checkbox” />多选按钮

5、<inputtype=“image” />图片

6、<inputtype=“file” />文件上传

7、<inputtype=“hidden” />隐藏域

8、<inputtype=“reset” />撤销按钮

9、<inputtype="submit" />提交按钮

10、<inputtype=“button” />普通按钮

11、多行文本输入标记<textarea>

<textarea name=“t1”,rows=x,cols=x>…

</textarea>

 name 设置识别名称。

 rows设置文本域的行数

 cols设置文本域的列数

 disabled设置文本为禁用

 warp 设置为off不换行

12、选择域<select>

   <select name=selectname>

   <option selected>选项一</option>

   < option >选项二</option>

  ……

  </select>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body >
<marquee direction="right" behavior="alternate" bgcolor="#3333FF">
hello,great boy.......
</marquee>
<hr>
<form>
输入单行文字 <input type="text" /><br>
输入密码 <input type="password" /><br>
单选按钮 <input type="radio" name="abc" /> <input type="radio" name="abc" /> <br>
多选按钮 <input type="checkbox" name="ab"/><input type="checkbox" name="ab"/> <br>
图片域 <input type="image" src="29.gif" /><br>
文件上传 <input type="file" /> <br>
隐藏域 <input type="hidden" /><br>
撤销按钮 <input type="reset" value="撤销按钮" /> <br>
提交按钮 <input type="submit" value="提交按钮" /> <br>
执行脚本 <input type="button" value="普通按钮" onclick="prompt() " /> <br>

<textarea name="t1" rows="4" cols="50">
文本域
</textarea>
<br>
<hr>
<select name="selectname">
<option>中国</option>
<option selected="selected">美国</option>
<option>日本</option>
</select>
</form>

</html>


HTML表单提交数据:html提交数据时必须设置<input>标签name和value属性,以便asp程序能获取相应的值。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body >
<form name="form1" action="request.asp" method="post">
<p>
请输入用户名: <input name="name" type="text" size="10" maxlength="7" />
<br>

请输入密码:
<input name="password" type="password" size="10" maxlength="6"/>
<br>
选择强项:<br>
体育<input type="checkbox" name="ck" value="体育" />
音乐<input type="checkbox" name="ck" value="音乐" />
跳舞<input type="checkbox" name="ck" value="跳舞" />
<br>
性别:<br>
男<input type="radio" name="sex" value="男" checked="checked" /> 女<input type="radio" name="sex" value="女" />
<br>

<select name="sn">
<option selected="selected"> 中国</option>
<option>美国</option>
<option>韩国</option>
</select>
<br>

<input name="确定" type="submit" id="确定" value="提交" />
<input name="重置" type="reset" value="重置">

<p>

</form>
</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: