View Full Version : Enable/thisable 2 radiobuttons with checkbox

05-02-2006, 05:33 PM

I want to be able to enable 2 radiobuttons of the same group by checking a checkbox and disable them when the box is unchecked.

I've found numerous scripts for enableing and disableing textfields and entire forms but none for radiobuttons of the same group. The script I have now (also from this forum from JohnKrutsch) is:

(simplified for the purpose of posting it here)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>enable/disable radiobuttons</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT TYPE="text/javascript" LANGUAGE="javascript">

function checkIt(toCheck,toEnable){
for(i=0;i<a.length;i++) document.form2[a[i]].disabled=!document.form2[toCheck].checked;



Check the checkbox to enable the radiobuttons.
<form action="bla.php" method="post" enctype="multipart/form-data" name="form2">
<strong>Enable the buttons</strong> <input type="checkbox" name="cb" value="checkbox" onClick="checkIt('cb','tx,tf')">

<input type="radio" name="tx" disabled>
<strong>Radio1 </strong><br>
<input type="radio" name="tx" disabled>
Textfield<input type="text" name="tf" disabled>


This works fine except for enableing or disableing the radiobuttons.

Is there any way to get this script to work for buttons of the same group? Or does anyone have another solution?

Thank you for reading this and a big thanks to all the people helping other people out :thumbsup: .


05-02-2006, 06:28 PM

f7, f40 and others

05-02-2006, 08:00 PM
Thanks a lot! Didn't try the first but the f40 script works for the radiobuttons.:thumbsup: :)