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

Selecting checkbox to show/hide images upon Selection

Community Beginner ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

I've used similar threads to try and troubleshoot my issue but I can't seem to find the answer.

 

Im' working on a company form that has multiple product selections. I've made each checkbox the same name with a different export value so the user can't select multiple checkboxes at once. 

 

I created a button field w/ an image icon to show when each checkbox is selected. The script I used is as follows:

this.getField("Image1").display = (event.target.value=="Off") ? display.hidden : display.visible;

 

The problem is... Even though the user can't select multiple checkboxes at once, multiple images are being shown on the screen. For example, if the user selects the "BOWL 1" checkbox, the correspoding image will appear. But, if the user selects the "BOWL 2" checkbox, the image for "BOWL 1" and "BOWL 2" are being shown even though the "BOWL 1" checkbox is no longer selected. Can someone please tell me what I'm doing wrong?

TOPICS
General troubleshooting , JavaScript , PDF forms

Views

1.7K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Jan 26, 2023 Jan 26, 2023

You can put script in hidden text field as custom calculation script, something like this:

this.getField("RFBPic").display = (this.getField("Bowl_es_prefill").valueAsString=="RFB") ? display.visible : display.hidden;
this.getField("RPBPic").display = (this.getField("Bowl_es_prefill").valueAsString=="RPB") ? display.visible : display.hidden;

 

Just continue adding other fields same way.

There is no field "RWBPic" in your file so fix that, also you have a lot of errors in your other scripts, you sh

...

Votes

Translate

Translate
Community Expert ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

Where does you use the script?

Votes

Translate

Translate

Report

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 ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

If I'm understanding your question correctly, the script was put in the first row of checkbox fields at the bottom of the page. See attached screenshot. Each checkbox has a corresponding field that should be visible when selected.

Votes

Translate

Translate

Report

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 ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

When you display a button hide the other buttons.

Votes

Translate

Translate

Report

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 ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

Thank you for the fast replies. Just a few questions:

 

1. Do you mind sharing a simple script for hiding the buttons? I'm not a coder by any means.

2. Do I apply the script to the checkbox or the buttons?

Votes

Translate

Translate

Report

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 ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

Hide a button :

this.getField("Image1").display = display.hidden;

Use it at the checkbox. 

Votes

Translate

Translate

Report

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 ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

You can put script in hidden text field as custom calculation script, something like this:

this.getField("RFBPic").display = (this.getField("Bowl_es_prefill").valueAsString=="RFB") ? display.visible : display.hidden;
this.getField("RPBPic").display = (this.getField("Bowl_es_prefill").valueAsString=="RPB") ? display.visible : display.hidden;

 

Just continue adding other fields same way.

There is no field "RWBPic" in your file so fix that, also you have a lot of errors in your other scripts, you should check console for errors and fix them all.

Votes

Translate

Translate

Report

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 ,
Jan 26, 2023 Jan 26, 2023

Copy link to clipboard

Copied

Thank you both for the help. I've managed to get the form working as I would like. 

 

For the errors, I've opened the Javascript debugger and I can see what you are talking about. I deleted the scripts causing the errors but the console is showing that the errors still exist. Can you explain why this is?

Votes

Translate

Translate

Report

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 ,
Jan 27, 2023 Jan 27, 2023

Copy link to clipboard

Copied

LATEST

Have you cleared the console?

Votes

Translate

Translate

Report

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