HTML学习三

今天主要学习的为JS和HTML标签的一起使用:

一、重定向:

<html>
<head>
<title>JavaScript1</title>
</head>
<script type="text/javascript" language="javascript">
function fun(value)
{
window.location = value;
}
</script>
<body>
<select name="url" onchange="fun(this.value)">
<option value="">==select==</option>
<option value="http://www.baidu.com">baidu</option>
<option value="http://www.sohu.com">sohu</option>
</select>
</body>
</html>

  HTML学习三

二、全选

<html>
<head>
<title>JavaScript2</title>
<script type="text/javascript" language="javascript">
function funAll()
{
if(document.all("email").length == undefined )
{
document.all("email").checked = document.all("selectall").checked;
}
else
{
var obj = document.all("email");
for( var x=0;x<obj.length;x++)
{
obj[x].checked = document.all("selectall").checked;
}
}
}
</script>
</head>
<body>
<form action="javascript1.html" name="myform">
<input type="checkbox" name="email"/>emailA<br/>
<input type="checkbox" name="email"/>emailB<br/>
<input type="checkbox" name="email"/>emailC<br/>
<input type="checkbox" name="email"/>emailD<br/>
<hr>
<input type="checkbox" name="selectall" onclick="funAll()">selecAll
</form>
</body>
</html>

  HTML学习三

三、单选

<html>
<head>
<title>JavaScript3</title>
<script type="text/javascript" language="javascript">
function visitSex()
{
var obj = document.all("sex");
if(obj.length == undefined )
{
alert(obj.value);
}
else
{
if(obj[0].checked)
{
alert("select is:"+obj[0].value);
}else
{
alert("select is:"+obj[1].value);
}
}
}
</script>
</head>
<body>
<input type="radio" name="sex" value="nan" checked="checked"/>man
  
<input type="radio" name="sex" value="nv" />woman
<hr/>
<input type="button" value="vistSex" onclick="visitSex()"/>
</body>
</html>

  

HTML学习三

上一篇:【CF】509E Pretty Song


下一篇:数据中台:前台调用能快速响应、数据口径一致(1)