Skip to main content
rakeshk21205956
Inspiring
April 18, 2020
Answered

Set 2 different Images to button Field as Caption/Icon to toggle between images

  • April 18, 2020
  • 2 replies
  • 1551 views

I have a button field which cycles through SELECT > MALE > FEMALE option for gender .

Below is the script:

if (event.target.buttonGetCaption()=="SELECT")

{event.target.buttonSetCaption("MALE");}

 

else if (event.target.buttonGetCaption()=="MALE")

{event.target.buttonSetCaption("FEMALE");}

 

else if (event.target.buttonGetCaption()=="FEMALE")

{event.target.buttonSetCaption("SELECT");}


I want instead of text MALE or FEMALE.. i want to put there small icon of male and female  don't want to use layer visibility or two buttons (hide/show)....... is it possible to put two different icons in the same button and cycle through.

 

Thanks

This topic has been closed for replies.
Correct answer rakeshk21205956

"picture1" is not an Icon... You need to use something like this:

event.target.buttonSetIcon(this.getField("picture1").buttonGetIcon());


it works fine

 

if (event.target.buttonGetIcon() == this.getField("picture1").buttonGetIcon())
{event.target.buttonSetIcon(this.getField("picture2").buttonGetIcon());}

else if(event.target.buttonGetIcon() == this.getField("picture2").buttonGetIcon())
{event.target.buttonSetIcon(this.getField("picture1").buttonGetIcon());}

 

 

Thanks for your help

2 replies

JR Boulay
Community Expert
Community Expert
April 18, 2020

See the free Import Icon tool on this page: http://practicalpdf.com/actions-and-commands/

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
Community Expert
April 18, 2020

Yes, but it's much trickier. You will need to save those icons as the icons of (hidden) button fields and then import them from those fields to the main field, as well as compare them to the current one.

rakeshk21205956
Inspiring
April 18, 2020

I tried doing that but it didnot worked:

var picture1 = this.getField("Button1");  //this is the field with image

 

if (event.target.buttonGetCaption()=="SELECT")

{event.target.buttonSetIcon("picture1");}

 

try67
Community Expert
Community Expert
April 18, 2020

"picture1" is not an Icon... You need to use something like this:

event.target.buttonSetIcon(this.getField("picture1").buttonGetIcon());