当谈到页面上的表单时,相信大家都不陌生了,注册登录什么的都要与表单打交道,现在让我们来看一下表单中最常见的标签用法.
<label>First Name</label>
<input type="text“ name="firstname"/> <br/>
<label> Last Name </label>
<input type="text" name="lastname"/>
<textarea name="description" readonly="readonly" rows=3 cols=40>
早上十点起床,泡制一壶新鲜的热咖啡,阅读报纸至中午,吃午餐,上画画/网球/kick
boxing课,看书,看《friends》,玩 Guitar Hero(电视游戏),再看书,睡觉
</textarea>
cols和rows属性分别指定文本宽的可见宽度与长度。readonly属性定义该文本宽只能读。
<label>Password</label>
<input type="password" name="password"/>
<input type="radio" id="male" name="gender" value="Male" checked="checked"/>
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="Female" />
<label for="female">Female</label>
<input type="checkbox" name="color[]" id="green" value="green" />
<label for="green">green</label>
<input type="checkbox" name="color[]" id="red" value="red"/>
<label for="red">red</label>
<input type="checkbox" name="color[]" id="blue" value="blue"/>
<labe for="blue">blue</label>
<select name="sport">
<option value="football">football</option>
<option value="baskeball">basketball</option>
<option value="baseball">baseball</option>
</select>
<select multiple="multiple" name="colors[]" size="5">
<option value="red"> red</option>
<option value="green"> green </option>
<option value="black">black</option>
<option value="blue">blue </option>
<option value="orange">orange</option>
</select>
单选列表添加multiple="multiple"属性就变成多选列表了,这时name一定要改为数组存储多个值,size属性定义可见选项的数目,一般很少用。需要说明的是,需用户按键盘来配合。
- 对于 windows:按住 Ctrl或shift 按钮来选择多个选项
- 对于 Mac:按住 command 按钮来选择多个选项
<input type="button" value="clickbutton"/>
用法很简单, 一般你想置入少量不可更改的信息时会用到。
<input type="file" value="uploadfile"/>
用到这个form必须设置属性method="post" enctype="multipart/form-data" 才行;
<input type="submit" name="submit" value="提交" />
<input type="reset" value="重置" />