function SelectAll(tempControl)
{
var theBox=tempControl;
xState=theBox.checked;
elem=theBox.form.elements;
for(i=0;i<elem.length;i++)
{
if(elem[i].type=="checkbox" && elem[i].id!=theBox.id)
{
if(elem[i].checked!=xState)
{
elem[i].click();
}
}
}
}
调用:onclick="javascript:SelectAll(this);"
{
var theBox=tempControl;
xState=theBox.checked;
elem=theBox.form.elements;
for(i=0;i<elem.length;i++)
{
if(elem[i].type=="checkbox" && elem[i].id!=theBox.id)
{
if(elem[i].checked!=xState)
{
elem[i].click();
}
}
}
}
调用:onclick="javascript:SelectAll(this);"
本文介绍了一个简单的JavaScript函数,用于实现网页表单中所有复选框的全选或全不选操作。通过点击一个指定的复选框,可以控制页面上其他复选框的状态。
1069

被折叠的 条评论
为什么被折叠?



