Copy link to clipboard
Copied
I have two image fields and images are read only. I have a text field and I want to swop images based on values. If the value is 0 or less than 0 like - 1 image1 and if +1 or greater than +1 then image2.
Is this possible?
Copy link to clipboard
Copied
Sure. As the custom validation script of the text field enter the following:
this.getField("image1").display = (event.value<=0) ? display.visible : display.hidden;
this.getField("image2").display = (event.value>0) ? display.visible : display.hidden;
Copy link to clipboard
Copied
Sure. As the custom validation script of the text field enter the following:
this.getField("image1").display = (event.value<=0) ? display.visible : display.hidden;
this.getField("image2").display = (event.value>0) ? display.visible : display.hidden;
Copy link to clipboard
Copied
You can read all about Hide/Show scripts here:
https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm?sd=40
Copy link to clipboard
Copied
Really magic. Just one more question. If the value is 0 then both images should be hidden. Can you please modify code?
Copy link to clipboard
Copied
You can see that the condition on the first line of code is event.value<=0 . This is read as "when the value is less than or equal to 0" . When the codition is satisfied the display setting for the field is set to display.visible . I think you can see how this works. If you want both images to be hidden, then the condition needs to be modified so that it is not true when the value is 0, i.e., remove the equals.
Copy link to clipboard
Copied
So kind of you. Thank you!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more