<html>
<head>
<script>
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
rnd.seed = (rnd.seed*9301+49297) % 233280;
var str=""+rnd.seed/(233280.0);
var array=str.split(".");
var str2=array[1];
var str3=str2.substring(0,6);
return str3;
};
function rand(number) {
return Math.ceil(rnd()*number);
};
</script>
<script>
function withdraw()
{
alert(document.Form1.ABC.length);
var counter=document.Form1.ABC.length;
for(i=0;i<counter;i++)
{
if(document.Form1.ABC[i].checked)
alert("第"+(i+1)+"个选择")
}
}
function check(obj)
{
for(i=0;i<document.all(obj).length;i++)
{
if(!document.all(obj)[i].checked)alert("第"+(i+1)+"个没有选择")
}
}
</script>
</script>
</head>
<title>
</title>
<body>
<div id="fsss">
<div id="fss">
<ul id="fs">
<form name="Form1" id="Form1">
<input name="allbox" type="checkbox" onClick="TA();" title="选中或清除选中所有的项目" tabindex="105">选中或清除选中所有的项目
<br/>
<span class="X"><input type="checkbox" name="ABC" id="ABC" class="A" value="abc" onClick="TTA(this);">清明时节</span>
<br/>
<span class="X"><input type="checkbox" name="ABC" id="DEF" class="A" onClick="TTA(this);">长江水啊</span>
<br/>
<span class="X"><input type="checkbox" name="ABC" id="GHL" class="A" onClick="TTA(this);">嘿嘿测试</span>
<br/>
<br/>
<input type="button" value="统一退订" onClick="withdraw();">
</form>
</ul>
</div></div>
<script language="javascript">
var frm = document.Form1;
</script>
<script language="JavaScript">
function TA(isO,noHL){
var trk = 0;
for(var i=0;i<frm.elements.length;i++){
var e=frm.elements[i];
if((e.name !='allbox') && (e.type == 'checkbox')){
e.checked = frm.allbox.checked;
if (frm.allbox.checked){
//e.parentElement.className = "H"; //.parentElement不兼容firefox浏览器
e.parentNode.className = "H";//调用设置父节点元素class改变背景色
}else{
e.parentNode.className = "X";//调用设置父节点元素class改变背景色
}
}
}
}
function TTA(CB,noHL){
if (CB.checked){
CB.parentNode.className = "H";
}else{
CB.parentNode.className = "X";
}
var TB=TO=0;
for (var i=0;i<frm.elements.length;i++){
var e=frm.elements[i];
if ((e.name != 'allbox') && (e.type=='checkbox')){
TB++;
if (e.checked)
TO++;
}
}
frm.allbox.checked=(TO==TB)?true:false;
//如果不是所有项被选中则allbox设定未被选中
}
</script>
<style>
.H{
background: #ADD8E6
}
.X{
background: #FFFFFF
}
</style>
</body></html>