你在 for 循环里比如说判断到了有 value=="新闻" 的条件时, 做完操作就应该 break 掉 for 的循环, 否则继续循环下去, 又变成了其它的赋值了.
function dotypeselect()
{
var objsel=document.all.im_type.options;
for(var i=0;i<objsel.length;i++)
{
if(objsel[i].value=="新闻")
{
document.all.im_c1.disabled=false;
return; //要学会中止循环呀
}
}
document.all.im_c1.disabled=true;
}
function dotypeselect()
{
var objsel=document.all.im_type.options;
for(var i=0;i<objsel.length;i++)
{
if(objsel[i].value=="新闻")
{
document.all.im_c1.disabled=false;
return; //要学会中止循环呀
}
}
document.all.im_c1.disabled=true;
}
"新闻"不是最后的话disabled永远false了
function dotypeselect()
{
var objsel=document.all.im_type.options;
for(var i=0;i<objsel.length;i++)
{
if(objsel[i].selected && objsel[i].value=="新闻")
{
document.all.im_c1.disabled=false;
return; //要学会中止循环呀
}
}
document.all.im_c1.disabled=true;
}
</SCRIPT><select size="1" name="im_type" id="im_type" onchange="dotypeselect()">
<option value="">请选择
<option value="新闻" selected>新闻
<option value="中止">中止
<option value="循环">循环
</select>
<input type="checkbox" name="C1" id="im_c1" value="ON" >
<SCRIPT LANGUAGE="JavaScript">
function dotypeselect(e, objId)
{
document.getElementById(objId).disabled = e.value!="新闻";
}
</SCRIPT><select size="1" name="im_type" onchange="dotypeselect(this, 'im_c1')">
<option value="">请选择
<option value="新闻" selected>新闻
<option value="中止">中止
<option value="循环">循环
</select>
<input type="checkbox" name="C1" id="im_c1" value="ON" >