您的位置:首页 > 其它

第007讲 表单及各种表单控件2

2016-11-21 18:42 225 查看
隐藏域:不希望影响界面效果。但又希望提交数据

各种类型标签以及隐藏域

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>表单元素</title>
</head>
<body>
<form action="?" method="GET">
您最喜欢那些城市:
<!-- 为了后边好统计数据建议name使用相同字段。why -->
<input type="checkbox" name="citys"/>北京
<input type="checkbox" name="citys"/>上海
<input type="checkbox" name="citys"/>伦敦
<input type="checkbox" name="citys"/>华盛顿
<br/>
您的性别是:
<input type="radio" name="sex"/>男
<input type="radio" name="sex"/>女
<br/>
隐藏域:
<input type="hidden" name="data" value="ok"/>
<input type="submit" name="git" value="提交"/>
</form>
</body>
</html>
008




在这里有个问题:

如上代码如果直接点击提交 submit 的话看链接

file:///D:/Editplus/othershow/loginsuccess.html?citys=on&sex=on&data=ok&git=%E6%8F%90%E4%BA%A4

会发现城市后边 包括sex 后边 都等于 on 但是data这个隐藏域为什么不等于on呢,观察会发现 哦 原来是因为 citys和sex我们并没有value赋值这样就造成了这个问题

那么我们试试加上value

结果如下:

file:///D:/Editplus/othershow/loginsuccess.html?citys=beijing&sex=nan&data=ok&git=%E6%8F%90%E4%BA%A4

那那那 有值了吧

最后还有个img按钮类型 照常理 src拿到图片地址就好

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>表单元素</title>
</head>
<body>
<form action="loginsuccess.html" method="GET">
您最喜欢那些城市:
<!-- 为了后边好统计数据建议name使用相同字段。why -->
<input type="checkbox" name="citys" value="beijing"/>北京
<input type="checkbox" name="citys" value="shanghai"/>上海
<input type="checkbox" name="citys" value="lundun"/>伦敦
<input type="checkbox" name="citys" value="huashengdun"/>华盛顿
<br/>
您的性别是:
<input type="radio" name="sex" value="nan"/>男
<input type="radio" name="sex" value="woman"/>女
<br/>
隐藏域:
<input type="hidden" name="data" value="ok"/>
<input type="submit" name="git" value="提交"/>
<input type="image" name="gitimage" src="go_home_and_shop.png"/>
<!--图片也能做按钮-->
</form>
</body>
</html>




select/option/textarea

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>表单元素</title>
</head>
<body>
<form action="loginsuccess.html" method="GET">
您最喜欢那些城市:
<!-- 为了后边好统计数据建议name使用相同字段。why -->
<input type="checkbox" name="citys" value="beijing"/>北京
<input type="checkbox" name="citys" value="shagnhai"/>上海
<input type="checkbox" name="citys" value="lundun"/>伦敦
<input type="checkbox" name="citys" value="huashengdun"/>华盛顿
<br/>
您的性别是:
<input type="radio" name="sex" value="nan"/>男
<input type="radio" name="sex" value="woman"/>女
<br/>
<!-- size 表示展示出几个 multiple 表示可以多选 -->
<select name="address" size=2 multiple>
<option value="sichuan">四川</option>
<option value="tianjin">天津</option>
<option value="shanghai">上海</option>
<option value="beijing">北京</option>
<select/>
<br/>
<!-- 文本域 加上name之后 点击确定可以带上文本域内容 -->
<textarea cols="20" rows="10" name="comment">

</textarea>

<br/>
<input type="file" name="myfile"/>上传文件
<br/>
隐藏域:
<input type="hidden" name="data" value="ok"/>
<input type="submit" name="git" value="提交"/>
<input type="image" name="gitimage" src="go_home_and_shop.png"/>
</form>
</body>
</html>


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