Skip navigation
Kelso@HillAero
Currently Being Moderated

Using a checkbox to disable a series of radio buttons

May 14, 2012 8:55 AM

Tags: #acrobat #field #javascript #form #radio #checkbox #fillable

Good morning ladies and gents,

 

I'm the process of converting a bunch of Word documents over to fillable PDFs.

The form I'm currently working on has checkboxes and radio buttons (along with several) text fields.

 

My question is this:

If the end-user marks a checkbox on one part of the form, I need it to disable the following five pairs of radio buttons.

 

I also need to implement this feature/script twice in the document.

 

I know this is possible, I'm just not sure how to go about it.

I've tried modifying several Javascript code segements found online, to no avail.

 

Any help would be greatly appreciated-- I can provide form names, screenshots of the documents and any other info upon request.

Thanks :]

 
Replies
  • Currently Being Moderated
    May 14, 2012 9:05 AM   in reply to Kelso@HillAero

    Are you using LiveCycle Designer or Acrobat Form Tools to create your form?

     

    Conditional Execution

     

    The value of the ceck box will be "Off" when not selected and the "Export Value" when selected. For a single check box you can easily use the 'isBoxChecked" method of the check box field.

     

     

     
    |
    Mark as:
  • Currently Being Moderated
    May 14, 2012 9:44 AM   in reply to Kelso@HillAero

    You need to access each group of radio buttons by their form field name and set the 'readionly" property to 'true".

     

    Since you need to process a block of commands, use the curly brackets to mark the block of code.

     

    You also need to process the form fields when the value is not "Yes".

     

    var cAgree = this.getField("Supplier_Info - DDC_None").value;

    if( cAgree == "Yes" ) {

    // make the following radio boxes read only

    var oField = this.getField("RadioBox 1");

    oField.readonly = true;

    oField = this.getField("RadioBox 2");

    oField.readonly = true;

    oField = this.getField("RadioBox 3");

    oField.readonly = true;

    } else {

    // make radio buttons RW

    var oField = this.getField("RadioBox 1");

    oField.readonly = false;

    oField = this.getField("RadioBox 2");

    oField.readonly = false;

    oField = this.getField("RadioBox 3");

    oField.readonly = false;

    } // end process radio buttons

     
    |
    Mark as:
  • Currently Being Moderated
    May 14, 2012 10:11 AM   in reply to Kelso@HillAero

    You have to call the funciton with a mouse up or on blur action with

     

    disable_radio_buttons_DDC()

     

    You may need to change:

     

    this.getField("Supplier_Info - DDC_None").value;

     

    to:

     

    this.getField(event.target.name).value;

     

    or event.value;

     

    since you are still in the field.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 4, 2012 7:26 AM   in reply to Kelso@HillAero

    Hi Kelso

     

    I have the same problem as you have had. I have tried to put in the code as above in my form. I don't know much about scripting, so where to put the OnMouseUp-event in the code I have no clue! None of the places where I tried did work.

    Can you show me in your code how you added the button name to the event?

     

    Thanks

    -Charlotte

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 4, 2012 8:12 AM   in reply to c-k-jensen

    Did you change the field names to match your form?

     

    Did you get any errors in the Acrobat JavaScript debugging console?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 15, 2012 4:24 AM   in reply to GKaiseril

    Hi GKaiseril

     

    I found a code expert who could help me out doing it in a very different way. He didn't know anything about Javascipting, though, so he also learned something new

     

    Thank you anyway

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 18, 2012 4:48 AM   in reply to GKaiseril

    Hi again GKaiseril

     

    So now I'm trying once more - and without my personal expert - to make a radio button exclusion. And I can't get it to do what I want!

     

    I have two sets of radio buttons: "RB1" and "RB2".

    In RB1 there is five possible choices: "C1-1", "C1-2", "C1-3", "C1-4", "C1-5".

    In RB2 there is four possible choices: "C2-1", "C2-2", "C2-3", "C2-4".

     

    (In my form they have different names, but this to make it easy.)

     

    So, what I need is to make C1-4 disable C2-4.

     

    If I type in what you learned Kelso:

     

    function Disable_C2-4()
    {
    var cAgree = this.getField("RB1").value;

    if( cAgree == "C1-4")
    {

    // make the following radio boxes read only

    var oField = this.getField("C2-4");

    oField.readonly = true;
    oField.value = "Off";

    }
    else
    {
    // make radio buttons RW

    var oField = this.getField("C2-4");

    oField.readonly = false;

    } // end process radio buttons

    }

     

    I get this error in the console:

     

    TypeError: oField is null

    12:Field:Mouse Up

     

    I can only make it work if I switch out "C2-4" with the whole set: "RB2". But then all the radio buttons in RB2 is made read only, and that isn't what I want.

     

    How can I access only one of the button choices?

    I hope you can help me since I need this type of function on several other forms.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 18, 2012 7:49 AM   in reply to Kelso@HillAero

    Hi Kelso

     

    Thank you for your reply.

    Actually, having two sets of radio buttons is the only way to make this simple and foolproof!

     

    So I hope somebody else knows a solution to this.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 6:44 AM   in reply to Kelso@HillAero

    No, that wouldn't work out right.

     

    I really don't understand if it's not possible to call just one option of the radio buttons...

    But I guess I will have to settle with an explaining text saying that the choice is not an option with the other choice - and hope that people will read it!

     

    Thank you for your time, Kelso.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 6:58 AM   in reply to Kelso@HillAero

    You can if you reference the "widget" of the check box or radio button, but this is very tricky and can be confusing.

     

    Field versus widget attributes

    defaultIsChecked

    Radio button fields

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 24, 2012 1:03 PM   in reply to GKaiseril

    Hi GKaiseil!

     

    Thank you so much for your help!

    I could use the hidden function. Though, the readonly and the hidden fuctions don't appear the same, they both do what I want (and prevent people from doing what I don't want them to), so I'm happy now!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points