Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Javascript fo If A & B are true then C?

Participant ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

Hi all, I am working on a form where users fill in a radio button and an answer is revealed. I've done this by setting all answers to be hidden behind white rectangles. When a user activates a particular radio button, the answer under the white rectangle is revealed. This is working great for one radio button controlling one answer. The code for each buton is something like this:

 

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

     this.getField("Pers_2").display = display.visible ;

     this.getField("Pers_3").display = display.visible ;

     this.getField("Pers_4").display = display.visible ;

 

Now the client wants the answer to be revealed by clicking a combination of two ratio buttons. I would describe this as “If A and B are true, then C.” Does anybody know how to write the javascript for this? Attached is a pdf with (a) the programmed one-button version and (b) the layout for the two-button version. If somebody can tell me how to construct the first statement, I can probably figure out the other three.

 

As always, thanks in advance to this great community.

TOPICS
JavaScript, PDF forms

Views

988

Likes

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

Adobe Community Professional , May 07, 2021 May 07, 2021

Likes

Translate

Translate
Adobe Community Professional ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

To do that you need to make radio buttons not mutually exclusive or you won't be able to check two buttons at the same time.

You can work with something like this:

if(a != "Off" && b != "Off")

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

Of course change a and b to combination of radio buttons you need.This will work if they are not as group, and if you make two groups (which i assume you will do) Then you will have to go for their choices (I see you have choices of (PIS,OIO,RIS,SIO) so then it would look something like this:

if(event.value == "PIS"  && this.getField("seldom").value == "RIS")

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

but it all depends do you use them as group or individually:

 

Likes

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
Participant ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

Nesa, thanks for the quick reply. The radio buttos are actually two pairs of seldom/often choices. That is to say, you have a choice between seldom/often for Initiates and another choice between seldom/often for Responds. Does that make sense?

Likes

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
Adobe Community Professional ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

Likes

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
Participant ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

LATEST

Nesa, this is perfect. Thank you! I don't know where you live but if you're ever in Toronto, look me up. I owe you a beer!

Likes

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