Skip to main content
This topic has been closed for replies.
Correct answer PDF Automation Station

That's exactly what my script does.  You need a trigger.  The mouseup action of the button is the trigger.  Calculation scripts only change when field values change.  An image added to a button field is not a value change.  What do you mean "prompt"?  If you insist on making this a custom calculation script in the text field you would change the script to the following (assuming "Button1" is the image field name):

var icn=this.getField("Button1").buttonGetIcon();
var status="Has image";
try{util.iconStreamFromIcon(icn)}catch(e){status="Does not have image."}
event.value=status;

You will still need to modify the mouseup action of the image field so the change happens immediately by adding this line of code to the mouse up action:

this.calculateNow();

1 reply

PDF Automation Station
Community Expert
Community Expert
November 12, 2024

In the mouse up action of the image you should this script:

event.target.buttonImportIcon();

Assuming the name of your text field is "Status", add the following script after the script above in the mouse up action of the button/image field:

var icn=event.target.buttonGetIcon();
var status="Has image";
try{util.iconStreamFromIcon(icn)}catch(e){status="Does not have image."}
this.getField("Status").value=status;
BSI13Author
Participant
November 12, 2024
I have tried to use this in a Calculate event of a text field to
automatically show the status but somehow it does not work immediately, you
need to make an input from another field to trigger it to calculate,,, what
I am trying to have is that it should immediately prompt in a text field
that a user has uploaded an image right after uploading an image field.
PDF Automation Station
Community Expert
Community Expert
November 12, 2024

That's exactly what my script does.  You need a trigger.  The mouseup action of the button is the trigger.  Calculation scripts only change when field values change.  An image added to a button field is not a value change.  What do you mean "prompt"?  If you insist on making this a custom calculation script in the text field you would change the script to the following (assuming "Button1" is the image field name):

var icn=this.getField("Button1").buttonGetIcon();
var status="Has image";
try{util.iconStreamFromIcon(icn)}catch(e){status="Does not have image."}
event.value=status;

You will still need to modify the mouseup action of the image field so the change happens immediately by adding this line of code to the mouse up action:

this.calculateNow();