新手关于JS的一个问题!高手快来帮我一下,十万火急……………………………………
小弟对js不是很熟,先跪求大侠帮小弟写一段js代码;
要求如下:有两个复选框A B,还有对应若干个复选框A1,A2,A3,A4 B1,B2,B3;当没有选中复选框A时,下面的A1,A2,A3,A4都无效,同样对应复选框B;也只有当A复选框选中时,下面的A1,A2,A3,A4才能有效,才能共用户选中;
请教大侠们一段代码,小弟感激不尽;
------解决方案--------------------测试可用
<script language= "javascript ">
function doclick(){
if (document.all.A.checked==true){
document.all.A1.disabled=false;
document.all.A2.disabled=false;
document.all.A3.disabled=false;
document.all.A4.disabled=false;
}
else{
document.all.A1.disabled=true;
document.all.A2.disabled=true;
document.all.A3.disabled=true;
document.all.A4.disabled=true;
document.all.A1.checked=false;
document.all.A2.checked=false;
document.all.A3.checked=false;
document.all.A4.checked=false;
}
}
</script>
<input type= "checkbox " name= "A " onclick= "doclick() ">
<input type= "checkbox " name= "A1 " onClick= "doclick " disabled>
<input type= "checkbox " name= "A2 " onClick= "doclick " disabled>
<input type= "checkbox " name= "A3 " onClick= "doclick " disabled>
<input type= "checkbox " name= "A4 " onClick= "doclick " disabled>
------解决方案-------------------- <html>
<head>
<script language= "javascript " type= "text/javascript ">
function Check(arg)
{
if(arg == "A " )
{
if( document.all( "A ").checked == true )
{
document.all( "A1 ").disabled = false;
document.all( "A2 ").disabled = false;
document.all( "A3 ").disabled = false;
document.all( "A4 ").disabled = false;
}
else
{
document.all( "A1 ").disabled = true;
document.all( "A2 ").disabled = true;
document.all( "A3 ").disabled = true;
document.all( "A4 ").disabled = true;
}
}
else if( arg == "B " )
{
if( document.all( "B ").checked == true )
{
document.all( "B1 ").disabled = false;
document.all( "B2 ").disabled = false;
document.all( "B3 ").disabled = false;
document.all( "B4 ").disabled = false;
}
else
{
document.all( "B1 ").disabled = true;
document.all( "B2 ").disabled = true;
document.all( "B3 ").disabled = true;
document.all( "B4 ").disabled = true;
}
}
}
</Script>
</head>
<body>
A <input type= "checkbox " value= "123 " onClick= "Check( 'A ') " name= "A ">
A1 <input type= "checkbox " value= "123 " disabled name= "A1 ">
A2 <input type= "checkbox " value= "123 " disabled name= "A2 ">
A3 <input type= "checkbox " value= "123 " disabled name= "A3 ">
A4 <input type= "checkbox " value= "123 " disabled name= "A4 ">
<br>
B <input type= "checkbox " value= "123 " onClick= "Check( 'B ') " name= "B ">
B1 <input type= "checkbox " value= "123 &qu