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

Javascript fo If A & B are true then C?

Contributor ,
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

1.6K

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

Votes

Translate

Translate
Community Expert ,
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:

 

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
Contributor ,
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?

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

Copy link to clipboard

Copied

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
Contributor ,
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!

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