Skip to main content
Known Participant
September 20, 2024
Answered

Show/hide labels/text boxes with a checkbox

  • September 20, 2024
  • 1 reply
  • 3285 views

Warning I know just enough to screw things up!

 

Looking to hide 3 fields based on the condition (checked or unchecked) of a checkbox.

 

Here are the fields:

  • cb_homeage (checkbox)
  • tb_yearbuilt (static label)
  • tb_homeyear (dynamic, inputs for the year it was built)
  • tb_homeage (calculated based on today's date - tb_homeyear)

 

If cb_homeage is checked, the three texboxes (tb_...) would be hidden

 

Here is what I have that is absolutely not working.

 

cb_homeage/Actions/Mouse Up/run javascript 

 

var fieldHide = event.target.isBoxChecked(0)?display.visable:display.hidden;

 

this.getField("tb_yearbuilt").display = fieldHide;
this.getField("tb_homeyear").display = fieldHide;
this.getField("tb_homeage").display = fieldHide;

 

One thing I am not sure about it the (and I'm sure I'm using the wrong terminology) checkbox identifier - so ...isBoxChecked(0) - not sure it's 0 (there are +/- 100 checkboxed and radio buttons)

 

This topic has been closed for replies.
Correct answer PDF Automation Station

Here is the whole document. Just did the page layouts and am trying to get page 1 figured out before fixing naming convenetions and such. Thanks in advance for the insight/help! 


The error is because cb_homeage is not defined (when there's no quotes around it it's a variable that hasn't been defined).  It should be replaced with 0 to determine whether the box is checked in the Mouse Up action.  You are also calling field names that do not exist in the rest of the script so there will more errors.  However, since the checkbox "cb_homeage" has no other copies it's a lot easier to use the following script:

var fieldHide=event.target.value=="Off"?display.hidden:display.visible;

//set display of your fields to fieldHide, example:

this.getField("tb_homeage").display = fieldHide;

1 reply

PDF Automation Station
Adobe Expert
September 20, 2024

The zero is for the first "widget" of the field, meaning the first in a series of check boxes that are named identically.  The widget numbers are in the order the fields were created starting with zero.  If this check box is the only one, then the zero would be correct to identify this check box.  However, your error is that you mispelled visible.

HambergAuthor
Known Participant
September 20, 2024

And that was a copy and paste :O/!!

 

How do I find the actual "ID" number for that check box?? There are 35+ check and radio button on this form page 

HambergAuthor
Known Participant
September 22, 2024

Your field is called "cb_homeage", not "cb_homepage"... Hence the error message you're getting.


@try67 I am not calling "cb_homepage" anywhere - what are you seeing that I'm not??