参考连接 http://www.irenezone.com/devarticles/article.jsf?articleId=11918<input type="checkbox" onclick="checkboxOnclick(this)" /><script>function checkboxOnclick(checkbox){if ( checkbox.checked == true){//Action for checked}else{//Action for not checked}}</script>
如果被选中了就执行你要执行的代码
如果没选中就什么都不执行,就可以
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script defer="defer">
function test(){
var $ = document.getElementById;
if($('checkBoxId').checked == true){
alert("选中");
subMit();
}
if($('checkBoxId').checked == false){
alert("未选中");
subMit1();
}
}
function subMit(){
alert("执行选中的函数");
}
function subMit1(){
alert("执行位选中的函数");
}
</script>
</head><body>
<input type="checkbox" name="checkbox" id="checkBoxId" value="checkbox" />
选中
<input name="" value="执行" type="button" onclick="test()" />
</body>
</html>
{
var ch1 = document.getElementsByName("delids");
for (var i=0;i<ch1.length;i++)
{
if (document.all.chek.checked)
{
ch1[i].checked=true;
}
else
{
ch1[i].checked=false;
}
}
}