JavaScript实现全选和反选 超简单
<body>
<form id="form1" runat="server">
请选择你的爱好:
<div>
<input name="Che" type="checkbox" />足球
<input name="Che" type="checkbox" />篮球
<input name="Che" type="checkbox" />上网
<input name="Che" type="checkbox" />游戏
<input name="Che" type="checkbox" />逛街
<input name="Che" type="checkbox" />购物
<input name="Che" type="checkbox" />排球
<input name="Che" type="checkbox" />看书
</div>
<input id="btnquan" type="button" onclick="quan()" value="全选" />
<input id="btnfan" type="button" onclick="fan()" value="反选" />
</form>
</body>
<script>
//全选的方法 超简单
function quanxuan()
{
//获得 所有的复选框
var che=document.getElementByName("Che");
//循环所有的复选框
for(var i=0;i<che.length;i++)
{
che[i].checked=true;
}
}
//反选的方法
function fanxuan()
{
//同样也是获得所有的复选框
var che=document.getElementByName("Che");
//同样for循环
for(var i=0;i<che.length;i++)
{
if(che[i].checked==true)
{
che[i].checked=false;
}
else
{
che[i].checked=true;
}
}
}
</script>
相关文档:
1、无提示关闭窗口
<input type="button" onClick="window.opener = '';window.close();" value="IE6最简单的无提示关闭窗口" >
2、防止被人iframe
if (top.location != self.location)
{
top.location.href="http://www.34do.net";
}
3、判断一个对象存在不存在
document.all("a")==null(不存在)
......
String
字符串对象。声明一个字符串对象最简单、快捷、有效、常用的方法就是直接赋值。
属性
length
用法:<字符串对象>.length;返回该字符串的长度。
方法
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>随机 ......
1.日期对象的构造
1.1当前日期
var now = new Date();
1.2特定日期
var someDate = new Date(yyyy,mm,dd);
注:月应该是从0开始计数的.
2. 日期函数的使用可以参照下面的链接. http://www.w3schoo ......
1问题来自一位网友的提问:
web页面里有多个表单,每个表单对应着某一类数据操作。
比如一个详细的简历信息页面分 1、个人资料 2、工作经验 3、项目经验 4、其他信息 4个表单。
一般的需求是允许用户单独提交其中任何一个表单到下一个页面进行修改操作(也就是说页面有4个不同的修改按钮,点击哪个按钮则只提交某一个表 ......