Hi,
I found this code that is almost perfect for my application… although I would like to include a text box too that responds to the different radio button states. I have tried a few different things on this line:
zxcgg.ary=zxcgg.getElementsByTagName(‘SELECT’);
but have been unsuccessful. Any help would be greatly appreciated. Thanks!
here’s my code… it works as is.
<html>
<head>
<title></title>
<script language=”JavaScript” type=”text/javascript”>
<!–
// by Vic Phillips (29-07-2005) [url]http://www.vicsjavascripts.org.uk
function zxcInitGroups(){
zxcg=zxcInitGroups.arguments;
for (zxc0=0;zxc0<zxcg.length;zxc0++){
zxcgg=document.getElementById(zxcg[zxc0]);
zxcgg.ary=zxcgg.getElementsByTagName(‘SELECT’,’TEXT’);
}
zxcD(document.getElementById(‘R1′),’group1′,’group2′,’group3’);
}
function zxcD(){
zxcg=zxcD.arguments;
zxcg1=document.getElementById(zxcg[1]).ary;
zxcg2=document.getElementById(zxcg[2]).ary;
if (zxcg[0].checked){
for (zxc0=0;zxc0<zxcg1.length;zxc0++){
zxcg1[zxc0].removeAttribute(‘disabled’)
}
for (zxc1=0;zxc1<zxcg2.length;zxc1++){
zxcg2[zxc1].setAttribute(‘disabled’,’disabled’)
}
}
else {
for (zxc2=0;zxc2<zxcg2.length;zxc2++){
zxcg2[zxc2].removeAttribute(‘disabled’)
}
for (zxc3=0;zxc3<zxcg1.length;zxc3++){
zxcg1[zxc3].setAttribute(‘disabled’,’disabled’)
}
}
}
//–>
</script>
</head>
<body onload=”zxcInitGroups(‘group1′,’group2′,’group3’);”>
<form>
1.
<input id=”R1″ type=”radio” name=”method” value=”1″ checked=’checked’ onclick=”zxcD(this,’group1′,’group2′,’group3′);” >
<span id=”group1″>
<select size=’1′ name=’id[143]’ >
<option value=’1′>blah</option>
</select>
</span>
<br><br>
2.
<input id=”R2″ type=”radio” name=”method” value=”individual” onclick=”zxcD(this,’group2′,’group1′,’group3′);” >
<span id=”group2″>
<select size=’1′ name=’id[450]’>
<option value=’1′>blah</option>
</select>
</span>
<br><br>
3.
<input id=”R3″ type=”radio” name=”method” value=”textBox” onclick=”zxcD(this,’group3′,’group1′,’group2′);” >
<span id=”group3″>
<input id=”3″ type=”text” name=”id[457]”>
</span>
</form>
</body>
</html>