These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Need to swap button icons

rhunter100
Registered: Dec 7 2009
Posts: 9

I need to swap icons to depict plot points for two separate measurement periods. In the retest condition (test == 2), a different .jpg is required. I've read the js Reference Manual for buttonSetIcon and buttonGetIcon but my efforts, while not creating any error messages, always fail to create the switch.

Please, any suggestions?

var scoreinput = 0;
var test = 0;

// Swap button icon.
var f = this.getField("ButtonIcon2");
var temp = f.buttonGetIcon();
f.buttonSetIcon(f.buttonGetIcon());
f.buttonSetIcon(temp);

scoreinput = scoreinput + this.getField("txtScoreInput").value;
var test = test + this.getField("Test").value;

if (test == 1 && scoreinput == 1){
this.getField("Button1").display = display.visible;
}

if (test == 2 && scoreinput == 1){
///////////Everything that I try here doesn't work
this.getField("Button1").display = display.visible;
}

Thanks for your help!

My Product Information:
Acrobat Pro 9.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
// Swap button icon.var f = this.getField("ButtonIcon2");var temp = f.buttonGetIcon();f.buttonSetIcon(f.buttonGetIcon()); // Sets button icon to itselff.buttonSetIcon(temp); // Does exactly the same thing over again

This code is getting the icon object from "ButtonIcon2" and then setting "ButtonIcon2" back to the same icon. I think you might need a reference to "Button1" here.

You need at least 3 buttons. One button for each image you want to store on the form (these should be hidden fields) and then one Button for each visible image. This way there is a clean division of labor. One set of buttons for storing images and one set of buttons for displaying images.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script