Jump to content

Help disabling radio buttons


kajj

Recommended Posts

Hi,

 

I have the following radio buttons:

 

<input type="radio" name="R5" value="1" checked> All<BR>

<input type="radio" name="R5" value="2"> Current<BR>

<input type="radio" name="R5" value="3"> Not Current<BR>

<input type="radio" name="R5" value="4"> Prior<BR>

<input type="radio" name="R5" value="5"> New<BR>

 

I am trying to disable them with no luck.  I am using the following function:

 

function ExternalData()

{

var the_box = window.document.form1.R32;

var the_switch = "";

if (the_box.checked == true) {

document.form1.R5.disabled = true ;

document.form1.R6.disabled = true ;

document.form1.R7.disabled = true ;

document.form1.R10.disabled = true ;

document.form1.R27.disabled = true ;

document.form1.R28.disabled = true ;

 

} else {

document.form1.R5.disabled = false ;

document.form1.R6.disabled = false ;

document.form1.R7.disabled = false ;

document.form1.R10.disabled = false ;

document.form1.R27.disabled = false ;

document.form1.R28.disabled = false ;

}

}

 

R10, R27, and R28 are checkboxes and dropdowns that disable correctly but I can't get the radio buttons to disable.  I'm fairly new to Javascript and I'm quite lost on how to do this.  Someone suggested using getelementbyid but everything I have looked at for that is a bit confusing.

 

Any help would be appreciated.

 

Thanks.

 

Link to comment
Share on other sites

After much trial and error, I finally got this to work.  I added IDs to all of my radio buttons and added the following code to the top of my function:

 

document.getElementById('IDR51').disabled= checked;

document.getElementById('IDR52').disabled= checked;

document.getElementById('IDR53').disabled= checked;

document.getElementById('IDR54').disabled= checked;

document.getElementById('IDR55').disabled= checked;

document.getElementById('IDR61').disabled= checked;

document.getElementById('IDR62').disabled= checked;

document.getElementById('IDR63').disabled= checked;

document.getElementById('IDR71').disabled= checked;

document.getElementById('IDR72').disabled= checked;

document.getElementById('IDR73').disabled= checked;

 

It is now turning the buttons on and off as needed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.