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/p/877569.html