js代码控制dropdownList

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"
>

< html >

< head >
< title ></ title >
< script  language ="JavaScript"  type ="text/javascript" >
<!--

// by Vic Phillips http://www.vicsjavascripts.org.uk

// elements in the form are numbered from the top 0 to 
//
 The select option value specifies the element numbers to disable separated by '^'

function Select(f,s){
el
=f.elements;
for (i=0;i<el.length;i++){
// el[i].style.visibility='visible';
el[i].removeAttribute('disabled');
}

if (s.selectedIndex<1)return; }
selop
=s.options[s.selectedIndex].value.split('^');
for (i=0;i<selop.length;i++){
if (el[selop[i]]){
// el[selop[i]].style.visibility='hidden';
el[selop[i]].setAttribute('disabled','disabled');
}

}

}


function Radio(f,s){
el
=f.elements;
for (i=0;i<el.length;i++){
// el[i].style.visibility='visible';
el[i].removeAttribute('disabled');
}

if (s.selectedIndex<1)return; }
selop
=s.value.split('^');
for (i=0;i<selop.length;i++){
if (el[selop[i]]){
// el[selop[i]].style.visibility='hidden';
el[selop[i]].setAttribute('disabled','disabled');
}

}

}


//-->
</ script ></ head >

< body >
< form  >
< select  name =""  size ="1"  onchange ="Select(this.form,this);" >
< option  value =" " > Select </ option >
< option  value ="1" > Hide TB1 </ option >
< option  value ="1^3" > Hide TB1 & 3 </ option >
< option  value ="2^3^4" > Hide TB2,3,4 </ option >
< option  value ="" > Hide None </ option >
</ select >
< input  name =""  size ="10"  value ="123" >
< input  name =""  size ="10"  value ="234" >
< input  name =""  size ="10"  value ="345" >
< input  name =""  size ="10"  value ="456" >
< input  type ="radio"  name ="fred"  value ="1"  onclick ="Radio(this.form,this);" >
< input  type ="radio"  name ="fred"  value ="1^3"  onclick ="Radio(this.form,this);" >
< input  type ="radio"  name ="fred"  value ="2^3^4"  onclick ="Radio(this.form,this);" >
< input  type ="radio"  name ="fred"  value =""  onclick ="Radio(this.form,this);" >< br >

</ form >
</ body >

</ html >


  < select  name ="first"  id ="first"  onchange ="if(this.value == 'no') document.getElementById('sec').disabled=true; else document.getElementById('sec').disabled=false;" >
            
< option  value ="yes" > Yes </ option >
            
< option  value ="no" > No </ option >
        
</ select >
        
< br  />< br  />
        
< select  name ="sec"  id ="sec" >
            
< option  value ="yes" > Yes </ option >
            
< option  value ="no" > No </ option >
        
</ select >

转载于:https://www.cnblogs.com/simhare/archive/2007/08/31/877569.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值