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

How do you show/hide buttons based on calculated result

Contributor ,
Aug 23, 2017 Aug 23, 2017

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript

Views

715

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 , Aug 23, 2017 Aug 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;

Votes

Translate

Translate
Community Expert ,
Aug 23, 2017 Aug 23, 2017

Copy link to clipboard

Copied

Sure. To show a field use this code:

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

To hide it:

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

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 ,
Aug 23, 2017 Aug 23, 2017

Copy link to clipboard

Copied

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

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 ,
Aug 23, 2017 Aug 23, 2017

Copy link to clipboard

Copied

That looks fine, yes.

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

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 ,
Aug 23, 2017 Aug 23, 2017

Copy link to clipboard

Copied

LATEST

Great!!

Thanks so much Try67 - works perfectly.

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