Skip to main content
Inspiring
August 23, 2017
Answered

How do you show/hide buttons based on calculated result

  • August 23, 2017
  • 1 reply
  • 1121 views

Hi,

I'm struggling with this; hopefully someone can help.

I'm creating a PDF that has some questions that are radio buttons with numeric values on each one. I'm wanting the sum of those selected to show a particular button - the result.

I've done something similar in the past, however that just populates a field with predefined text and colours the box - in this instance I'm wanting to show/hide a button as I was hoping to do a graphical answer as opposed to just words.

Here's the script I'd use previously:

var nResult = this.getField(“XXXXXX”).value;

if ( nResult > 14 ) {

event.value = “XXXXXXX”;

event.target.textColor = ["RGB", 1, 1, 1];

event.target.fillColor = ["RGB", 0, 0.454902, 0.482353];

}

else if( nResult > 7 ) {

event.value = “XXXXXXX”;

event.target.textColor = ["RGB", 0.113725, 0.113725, 0.105882];

event.target.fillColor = ["RGB", 1, 0.780392, 0.345098];

}

else {

event.value = “XXXXXXXXX”;

event.target.textColor = ["RGB", 0.113725, 0.113725, 0.105882];

event.target.fillColor = ["RGB", 0.937255, 0.262745, 0.219608];

}

Can this be done? any help would be hugely appreciated.

Huge thanks in advance

This topic has been closed for replies.
Correct answer try67

Sure. To show a field use this code:

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

To hide it:

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

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 23, 2017

Sure. To show a field use this code:

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

To hide it:

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

Inspiring
August 23, 2017

Hi Try67,

Great - thank you so, just to make sure i'm not being stupid - my code would be something like this?

var nResult = this.getField("XXXXXX").value;

if ( nResult > 14 ) {

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

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

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

}

else if( nResult > 7 ) {

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

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

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

}

else {

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

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

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

}

Thanks

try67
Community Expert
Community Expert
August 23, 2017

That looks fine, yes.

On Wed, Aug 23, 2017 at 12:00 PM, soulglowdeej <forums_noreply@adobe.com>