<!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=gb2312" />
<title>无标题文档</title>
<script defer="defer">
function test(){
var $ = document.getElementById;
if($('checkBoxId1').checked == true){
alert("1选中");
subMit();
}
if($('checkBoxId2').checked == true){
alert("2选中");
subMit3();
}
if($('checkBoxId1').checked == false){
alert("1未选中");
subMit1();
}
if($('checkBoxId1').checked == false){
alert("2未选中");
subMit2();
}
}
function subMit(){
alert("1执行选中的函数");
}
function subMit3(){
alert("2执行选中的函数");
}
function subMit1(){
alert("1执行未选中的函数");
}
function subMit2(){
alert("2执行未选中的函数");
}
</script>
</head>
<body>
<input type="checkbox" name="checkbox1" id="checkBoxId1" value="checkbox" onclick="test()" checked/>
业务
<input type="checkbox" name="checkbox2" id="checkBoxId2" value="checkbox" onclick="test()" checked/>
通用
协议 <textarea id="text" rows="5" cols="10" > </textarea >
</body>
</html>
<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($('checkBoxId1').checked == true){
alert("1选中");
subMit();
}
if($('checkBoxId2').checked == true){
alert("2选中");
subMit3();
}
if($('checkBoxId1').checked == false){
alert("1未选中");
subMit1();
}
if($('checkBoxId1').checked == false){
alert("2未选中");
subMit2();
}
}
function subMit(){
alert("1执行选中的函数");
}
function subMit3(){
alert("2执行选中的函数");
}
function subMit1(){
alert("1执行未选中的函数");
}
function subMit2(){
alert("2执行未选中的函数");
}
</script>
</head>
<body>
<input type="checkbox" name="checkbox1" id="checkBoxId1" value="checkbox" onclick="test()" checked/>
业务
<input type="checkbox" name="checkbox2" id="checkBoxId2" value="checkbox" onclick="test()" checked/>
通用
协议 <textarea id="text" rows="5" cols="10" > </textarea >
</body>
</html>
var intSelLength = 0; document.forms[0].leftext.options.length = 0;
for (var i=0;i<document.forms[0].checkbox.length;i++) {
if(document.forms[0].checkbox[i].checked==true){
switch(i){
case 0:
document.forms[0].leftext.options[intSelLength] = new Option("a","0");
document.forms[0].leftext.options[intSelLength + 1] = new Option("b","1");
intSelLength += 2;
break;
case 1:
document.forms[0].leftext.options[intSelLength] = new Option("e","0");
document.forms[0].leftext.options[intSelLength + 1] = new Option("f","1");
intSelLength += 2;
break;
}
}
}
}<input type="checkbox" name="checkbox" value="1" onclick="fn_add();">业务协议
<input type="checkbox" name="checkbox" value="2" onclick="fn_add();">通用协议<select name="leftext"></select>