代码可以实现,但很烂,那位大虾帮忙改一下,顺便散分

sealike 2005-06-08 04:05:39
<script language="javascript">

function ChgStatus1(){
opcontent1.checked=false;
opcontent2.checked=false;
opcontent3.checked=false;
opcontent4.checked=false;
opcontent1.disabled=true;
opcontent2.disabled=true;
opcontent3.disabled=true;
opcontent4.disabled=true;
opcontent5.disabled=false;
opcontent6.disabled=false;
opcontent7.disabled=false;
opcontent8.disabled=false;
}

function ChgStatus2(){
opcontent5.checked=false;
opcontent6.checked=false;
opcontent7.checked=false;
opcontent8.checked=false;
opcontent5.disabled=true;
opcontent6.disabled=true;
opcontent7.disabled=true;
opcontent8.disabled=true;
opcontent1.disabled=false;
opcontent2.disabled=false;
opcontent3.disabled=false;
opcontent4.disabled=false;
}
function ChgStatus3(){
opcontent1.checked=false;
opcontent2.checked=false;
opcontent3.checked=false;
opcontent4.checked=false;
opcontent5.checked=false;
opcontent6.checked=false;
opcontent7.checked=false;
opcontent8.checked=false;
opcontent1.disabled=true;
opcontent2.disabled=true;
opcontent3.disabled=true;
opcontent4.disabled=true;
opcontent5.disabled=true;
opcontent6.disabled=true;
opcontent7.disabled=true;
opcontent8.disabled=true;
}
</script>
<input type="radio" class="radio" size="10" name="cfcf" id="cfyou" onclick="ChgStatus1();"></input>
<input type="checkbox" class="checkbox" name="opcontent1" value="1" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent2" value="2" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent3" value="3" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent4" value="4" id="opcontent">

<input type="radio" class="radio" size="10" name="cfcf" id="cfwu" onclick="ChgStatus2();"></input>


<input type="checkbox" class="checkbox" name="opcontent5" value="5" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent6" value="6" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent7" value="7" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent8" value="8" id="opcontent">


<input type="radio" class="radio" size="10" name="cfcf" id="cfwu" onclick="ChgStatus3();"></input>
...全文
118 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
adam 2005-06-08
  • 打赏
  • 举报
回复
8错
wxylvmnn 2005-06-08
  • 打赏
  • 举报
回复
统一的名字

默认就是数组了!!

sealike 2005-06-08
  • 打赏
  • 举报
回复
to net_lover(孟子E章)
循环加选择,执行应该更耗资源吧

如果把所有的checkbox改称统一的名字,怎样识别呢?
ice_berg16 2005-06-08
  • 打赏
  • 举报
回复
<script language="javascript">

/* 使用方法
** 第一个参数为要disabled的checkbox的name,如果为多个用,隔开
** 第二个参数为要enabled的checkbox的name,如果多个用,隔开
*/
function ChgStatus(el){
elArr = el.split(",");
for(i=0;i<elArr.length;i++)
{
var op = document.getElementsByName(elArr[i]);
for(j=0;j<op.length;j++)
{
op[j].checked = false;
op[j].disabled = true;
}
}
if(arguments.length >1 )
{
elArr = arguments[1].split(",");
for(i=0;i<elArr.length;i++)
{
var op = document.getElementsByName(elArr[i]);
for(j=0;j<op.length;j++)
{
op[j].checked = false;
op[j].disabled = false;
}
}
}
}

</script>
<input type="radio" class="radio" size="10" name="cfcf" id="cfyou" onclick="ChgStatus('op1','op2');"></input>
<input type="checkbox" class="checkbox" name="op1" value="1">
<input type="checkbox" class="checkbox" name="op1" value="2">
<input type="checkbox" class="checkbox" name="op1" value="3">
<input type="checkbox" class="checkbox" name="op1" value="4">

<input type="radio" class="radio" size="10" name="cfcf" id="cfwu" onclick="ChgStatus('op2','op1');"></input>


<input type="checkbox" class="checkbox" name="op2" value="5">
<input type="checkbox" class="checkbox" name="op2" value="6">
<input type="checkbox" class="checkbox" name="op2" value="7">
<input type="checkbox" class="checkbox" name="op2" value="8">


<input type="radio" class="radio" size="10" name="cfcf" id="cfwu" onclick="ChgStatus('op1,op2');"></input>
孟子E章 2005-06-08
  • 打赏
  • 举报
回复
<script language="javascript">

function ChgStatus(n){
switch(n)
{
case 1:
for(i=1;i<5;i++)
{
eval("opcontent"+i+".checked=false")
eval("opcontent"+i+".disabled=true")
}
for(i=5;i<9;i++)
{
eval("opcontent"+i+".disabled=false")
}
break;

case 2:
for(i=1;i<5;i++)
{
eval("opcontent"+i+".disabled=false")
}
for(i=5;i<9;i++)
{
eval("opcontent"+i+".checked=false")
eval("opcontent"+i+".disabled=true")
}
break;

case 3:
for(i=1;i<9;i++)
{
eval("opcontent"+i+".checked=false")
eval("opcontent"+i+".disabled=true")
}

break;
}
}

</script>
<input type="radio" class="radio" size="10" name="cfcf" id="cfyou" onclick="ChgStatus(1);"></input>
<input type="checkbox" class="checkbox" name="opcontent1" value="1" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent2" value="2" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent3" value="3" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent4" value="4" id="opcontent">

<input type="radio" class="radio" size="10" name="cfcf" id="cfwu" onclick="ChgStatus(2);"></input>

<input type="checkbox" class="checkbox" name="opcontent5" value="5" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent6" value="6" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent7" value="7" id="opcontent">
<input type="checkbox" class="checkbox" name="opcontent8" value="8" id="opcontent">

<input type="radio" class="radio" size="10" name="cfcf" id="cfwu" onclick="ChgStatus(3);"></input>

87,919

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧