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

Javascript for Layers & Checkboxes

Community Beginner ,
Oct 18, 2021 Oct 18, 2021

I am working with Layers in my Form, but the visibility is based on what checkboxes are selected.  I have been able to set the layers if just a SINGLE checkbox is selected, but I am not sure how to code if multiple checkboxes are selected. 

 

For example  - If Checkbox1, Checkbox2, and Checkbox3 selected, then the Checkbox Layer1, Checkbox Layer2, and Checkbox Layer3 will display.  Do I have to create a single layer and Javascript a If/else statement for the Checkbox3?

TOPICS
Create PDFs , General troubleshooting , How to , JavaScript , PDF forms
1.3K
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 ,
Oct 18, 2021 Oct 18, 2021

Is the relation between one check-box and one layer, or multiple check-boxes to multiple layers, or a single check-box to multiple layers? Please clarify how it should work, exactly.

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 Beginner ,
Oct 18, 2021 Oct 18, 2021

So it could be either one check-box to one layer, or multiple checkboxes to multiple layers.  So if I had 3 checkboxes and 3 layers - and the individual selects checkbox#2, it will display layer#2 on a certain position of the form.  OR all 3 checkboxes are selected, it will display all 3 layers right after other on the form. 

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 ,
Oct 18, 2021 Oct 18, 2021

Layers don't have positions, they cover an entire page (although they can be partially transparent). They also don't have a stacking order.

Anyway, what you describe is just a one-to-one relationship between a check-box and a layer, which you said you were already able to implement, so I'm not sure what it is you need help with, exactly...

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 Beginner ,
Oct 18, 2021 Oct 18, 2021

I probably should provide background on my layers - they contain text fields and other checkboxes that need completed dependent on teh checkbox that was selected.  So I guess I have two questions: 

 

1) If I select 1 checkbox, and then unselect that same box, how to I get the layer to show, then hide again?  I can get it to show, but it won't hide when I uncheck the box?  

 

2) If I have multiple checkboxes selected, how do I get all those layers to show? In the correct order - for instance, boxes 1,3,and 5 are checked, so I need to show the additional text fields for those checkboxes.  

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 ,
Oct 18, 2021 Oct 18, 2021

Layers also don't contain form fields (normally), so I think what you're calling "layers" are not what is traditionally referred to as such in PDF files. Could you provide a sample file that shows some of these "layers"?

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 Beginner ,
Oct 18, 2021 Oct 18, 2021

I have attached the file.  I started javascripting using rect, but was having a hard time getting the fields to format correctly.  Someone suggested the "Layers" option to use with my checkboxes.  I am just trying to get the hidden text fields to display in order dependent on the checkboxes that are selected.  As the way I originally had it coded the there were blank spaces/pages, making my form longer than it needed to be. 

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 ,
Oct 20, 2021 Oct 20, 2021
LATEST

In this file I can see only checkboxes. What fileds want you show/hide?

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