<!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>张力仪</title>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
window.onload=function(){
var selectAll = $("selectAll"),
unSelect = $("unSelect"),
inputs=document.getElementsByName(‘range‘),
len = inputs.length;
selectAll.onclick=function(){
for(var i=0; i<len;i++){
inputs[i].checked=true;
}
}
unSelect.onclick=function(){
for(var i=0; i<len;i++){
var o = inputs[i];
o.checked?o.checked=false:o.checked=true;
}
}
}
</script>
</head>
<body>
<form name="form1" >
<input type="checkbox" value="1" name="range">
1<br>
<input type="checkbox" value="3" name="range">
3<br>
<input type="checkbox" value="4" name="range">
4<br>
<input type="checkbox" value="5" name="range">
5<br>
<input type="button" value="全选" id="selectAll">
<input type="button" value="反选" id="unSelect">
</form>
</body>
</html>