Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

show/hide a group of radiobuttons

Explorer ,
Mar 30, 2018 Mar 30, 2018

I haven Acro Form. There is a button in that form to show/hide other fields.

Normally, I assign a mouse up event and run a javascript as shown in the following example:

var oChkFld = this.getField("0_HiddenCheck_HideShow"); 

oChkFld.checkThisBox(0,!oChkFld.isBoxChecked(0)); 

this.getField("0_question_title").display = (oChkFld.value=="Off") ? display.hidden : display.visible;

And it works perfect.

But when it comes to the radio buttons, it does not function.

I indicate the group name of the corresponding radio buttons.

Example:

There is a group name of radio buttons called: "Collection_Extendibility" and inside there are options of "changing", "closed", etc.

So I write:

var oChkFld = this.getField("0_HiddenCheck_HideShow"); 

oChkFld.checkThisBox(0,!oChkFld.isBoxChecked(0)); 

this.getField("Collection_Extendibility").display = (oChkFld.value=="Off") ? display.hidden : display.visible;

But it does nothing.

TOPICS
PDF forms
880
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 02, 2018 Apr 02, 2018
LATEST

Radio buttons and check boxes are very much alike. When nothing is checked/selected, the output value is "Off", but if something is checked then the output value is the "Export Value" for the checked button/checkbox.

The technique you are using for checkboxes avoids dealing with the export value by always looking for the "Unchecked" value. But you can't do that with radio buttons because you've got more than one in the group. 

Another issue, and the only real difference between checkboxes and radio buttons, is that checkboxes turn both on and off, but radiou buttons only turn on.  This actually makes radio buttons easier.

So you need to put the script for changing visibility into every radio button in the group. Do not test for any values. Just put the show or hide code into the appropriate button.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines