webveuje/teaching/lhj/kejian/biaodan.html
2021-04-29 17:16:40 +08:00

83 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.btn{
width:70px;
height: 30px;
background: pink;
color:white;
text-align: center;
line-height: 30px;
cursor: pointer;
}
</style>
</head>
<body>
<!--
输入框
密码框
单选框
复选框
下拉框
文本框
按钮
-->
<form action="">
<div>
帐号 <input type="text" id="account"/>
</div>
<div>
密码 <input type="password" id="pwd">
</div>
<div>
性别 <input type="radio" name="sex" id="boy" value="nan"> <label for="boy"></label>
<input type="radio" name="sex" id="girl" value="nv" checked="checked"><label for="girl"></label>
</div>
<div>
爱好 <input type="checkbox" /> 读书
<input type="checkbox" /> timi
<input type="checkbox"> 追星
<input type="checkbox"> 听音乐
</div>
<div>
地址 <select name="" id="addr">
<option value="taohuayuan">桃花源</option>
<option value="tianya">天涯海角</option>
<option value="mxb">魔仙堡</option>
<option value="xizang">西藏</option>
<option value="budalagong">布达拉宫</option>
</select>
</div>
备注:<textarea name="" id="beizhu" cols="30" rows="10" ></textarea>
<div class="btn" onclick="save()">提交</div>
</form>
<noscript>
您的浏览器不支持js语法
</noscript>
<script>
function save(){
var account= document.getElementById("account").value
var pwd= document.getElementById("pwd").value
var beizhu=document.getElementById("beizhu").value
var addr=document.getElementById("addr").value
var sex=document.getElementsByName("sex")
var xingbie
console.log(account,pwd,beizhu)
console.log(sex[1].checked)
if(sex[0].checked){
xingbie="nan"
}else{
xingbie="nv"
}
console.log(xingbie)
}
</script>
</body>
</html>