Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable/enable forms depending on option box selected 1

Status
Not open for further replies.

altctrldel

Technical User
Jul 26, 2003
30
well; lemme give a visual example;


There will be 2 forms; one for the set A and another for set B.

depending on wheter option box A is selected, all the input check boxes/submit button in set B is disabled and vice versa.

the option boxes must always be enabled.

Can someone point me to a tutorial or topic or a simpler example on how I can achieve this? thanks.
 
How about doing a search locally!

Both his forum and the HTML forum (forum215) have had a bunch of threads discussing making forms (and form elements) disabled/enabled based on actions (including using radios and checkboxes to determine this).

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
some one posted this before;

<html>

<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--
// by Vic Phillips (29-07-2005)

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>

<select size='1' name='id[144]' >
<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">
<input type="checkbox" name='id[450]' value="1" >Wassup
<input type="checkbox" name='id[451]' value="2" >2nd
<input type="checkbox" name='id[452]' value="3" >3rd
</span>
</form>
</body>

</html>
It used to work for select boxes but when i changed it to check boxes it just wont disable. help. ^^
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top