首页 > 代码库 > 第四讲:html的使用(三)

第四讲:html的使用(三)

凡事欲其成功,必要付出代价:奋斗。——爱默生


本讲内容:表单form元素


一、表单form元素介绍:html 的表单元素,主要用于让用户输入数据,并提交给服务器。

基本语法:

<form action = “url”method = “提交的方法(get/post),默认是get”>

各种元素[输入框,下拉列表,文本域,密码框。。。]

</form>


get与post区别:post 表单的内容通过http发送,在地址栏中看不到表单的提交信息


表单常用控件

属性描述
input type="text"单行文本输入框
input type=“password”密码输入框
input type="radio"单选框
input type="checkbox"复选框
select列表框
textarea多行文本输入框
input type="submit"将表单内容提交给服务器的按钮
input type="reset"将表单全部内容全部清除,重新填写的按钮
input type = "image" src=http://www.mamicode.com/
图片
  

案例1

<html>
<head>
<title>登入界面 </title>
</head>
<body>
<h1>登入界面</h1>
<form action ="ok.html" method = "get">
用户名: <input type = "text" name ="username"/><br/>
密  码:<input type = "password" name ="pwd"/><br/>
<input type = "submit" value = http://www.mamicode.com/"登入"/>>


案例2

*****喜欢水果*****<br/>
<input type = "checkbox" name ="v1">西瓜<br/>
<input type = "checkbox" name ="v1">苹果<br/>

*****喜欢性别*****<br/>
<input type = "radio" name ="sex"/>男<br/>
<input type = "radio" name ="sex"/>女<br/>

*****隐藏(它的用处主要是,既可以提交数据,同时不影响界面)*****<br/>
<input type = "hidden"  value = http://www.mamicode.com/"123"  name ="sal"/>>

本讲就到这里,Take your time and enjoy it


第四讲:html的使用(三)