Skip to main content
Known Participant
August 20, 2020
Answered

radio button and values

  • August 20, 2020
  • 3 replies
  • 1035 views

I have a group of 2 radio buttons in two lines, related to the first the values a, b, (a*b)

the second line a1, b1, (a1*b1). in a pdf form

 

I would like to have a script that gives the following:

if RB1 is checked the values a, b, a*b will appear, if RB2 is checked RB1 line will show no values and values in RB2 will appear and vice versa...

 

RB1       a              b                 a*b

RB2       a             b1              a1*b1

 

Thanks

This topic has been closed for replies.
Correct answer ls_rbls

I'm assuming that the pair of RadioButtons aremutually exclusive( both fields assigned the same fieldname but a different export value).

 

In the example below, I named the radio buttons fields as "RB", then assign export values of "RB1" and "RB2" respectively.

 

The caluclating fileds are named with the same labels that you used in your inquiry to make it easier to visualize.

 

You can use the  following script as a custom calculation script in the  the (a*b) total field, for example:

 

event.value = this.getField("a").value *  this.getField("b").value; 


var f = this.getField("RB");

if (f.value == "RB1") {
this.getField("a").display = display.visible;
this.getField("b").display = display.visible;
event.target.display = display.visible;
} else {
this.getField("a").display = display.hidden;
this.getField("b").display = display.hidden;
event.target.display = display.hidden;
 } 

 if (f.value == "RB2") {
this.getField("a1").display = display.visible;
this.getField("b1").display = display.visible;
this.getField("ab1").display = display.visible;

} else {

this.getField("a1").display = display.hidden;
this.getField("b1").display = display.hidden;
this.getField("ab1").display = display.hidden;

}

 

 

 

3 replies

Known Participant
August 20, 2020

Thanks a lot, it works perfectly!

I do appreciate your help.

Known Participant
August 20, 2020

Yes, please.

ls_rbls
Community Expert
ls_rblsCommunity ExpertCorrect answer
Community Expert
August 20, 2020

I'm assuming that the pair of RadioButtons aremutually exclusive( both fields assigned the same fieldname but a different export value).

 

In the example below, I named the radio buttons fields as "RB", then assign export values of "RB1" and "RB2" respectively.

 

The caluclating fileds are named with the same labels that you used in your inquiry to make it easier to visualize.

 

You can use the  following script as a custom calculation script in the  the (a*b) total field, for example:

 

event.value = this.getField("a").value *  this.getField("b").value; 


var f = this.getField("RB");

if (f.value == "RB1") {
this.getField("a").display = display.visible;
this.getField("b").display = display.visible;
event.target.display = display.visible;
} else {
this.getField("a").display = display.hidden;
this.getField("b").display = display.hidden;
event.target.display = display.hidden;
 } 

 if (f.value == "RB2") {
this.getField("a1").display = display.visible;
this.getField("b1").display = display.visible;
this.getField("ab1").display = display.visible;

} else {

this.getField("a1").display = display.hidden;
this.getField("b1").display = display.hidden;
this.getField("ab1").display = display.hidden;

}

 

 

 

ls_rbls
Community Expert
Community Expert
August 20, 2020

Are you asking about hiding the fields ?