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.
See if this works for you:
https://drive.google.com/uc?export=download&id=1mk-FDY_SOTif_O520kS49CGaFWXgC8QC
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:
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?
Copy link to clipboard
Copied
See if this works for you:
https://drive.google.com/uc?export=download&id=1mk-FDY_SOTif_O520kS49CGaFWXgC8QC
Copy link to clipboard
Copied
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!