Copy link to clipboard
Copied
Hi all,
Have an issue with attempting to get image fields to either become visible, or hidden - depending on the 3-letter text value that is entered in a field.
I have the fields name as follows;
"Leg1" - text in 3-letter format is entered here, e.g. "ERF", "PAD", "BCN" & "STN".
"Fuellleg1_1" - dsiplays an icon only
"Fuellleg1_2" - dsiplays an icon only
"Fuellleg1_3" - dsiplays an icon only
If the text of either/or "ERF", or "PAD" is entered in to the "Leg1" field, then the "Fuellleg1_1" field shoud be displayed in either/or case, and the "Fuellleg1_2" and "Fuellleg1_3" fields should be hidden.
If the text "BCN" is entered in to the "Leg1" field, then the "Fuellleg1_2" field should be displayed, and the "Fuellleg1_1" and "Fuellleg1_3" fields should be hidden.
If the text "STN" is entered in to the "Leg1" field, then the "Fuellleg1_3" field should be displayed, and the "Fuellleg1_1" and "Fuellleg1_2" fields should be hidden.
If there is no text , e.g. " " is entered in to the "Leg1" field, then the "Fuellleg1_1", "Fuellleg1_2" and "Fuellleg1_3" fields (i.e. all of the fields) should be hidden.
Any ideas? I've tried alas in various ways but to no effect....
Copy link to clipboard
Copied
As Bernd suggests, a validation script on the "Leg1" field is a good choice.
For example:
switch(event.value)
{
case "PAD":
case "ERF":
this.getField("Fuellleg1_1").display = display.visible;
this.getField("Fuellleg1_2").display = display.hidden;
this.getField("Fuellleg1_3").display = display.hidden;
break;
case "BCN":
this.getField("Fuellleg1_1").display = display.hidden;
this.getField("Fuellleg1_2").display = display.visible;
this.getField("Fuellleg1_3").display = display.hidden;
break;
case "STN":
this.getField("Fuellleg1_1").display = display.hidden;
this.getField("Fuellleg1_2").display = display.hidden;
this.getField("Fuellleg1_3").display = display.visible;
break;
default:
this.getField("Fuellleg1_1").display = display.hidden;
this.getField("Fuellleg1_2").display = display.hidden;
this.getField("Fuellleg1_3").display = display.hidden;
break;
}
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
You can use a validation script at field "Leg1".
Copy link to clipboard
Copied
As Bernd suggests, a validation script on the "Leg1" field is a good choice.
For example:
switch(event.value)
{
case "PAD":
case "ERF":
this.getField("Fuellleg1_1").display = display.visible;
this.getField("Fuellleg1_2").display = display.hidden;
this.getField("Fuellleg1_3").display = display.hidden;
break;
case "BCN":
this.getField("Fuellleg1_1").display = display.hidden;
this.getField("Fuellleg1_2").display = display.visible;
this.getField("Fuellleg1_3").display = display.hidden;
break;
case "STN":
this.getField("Fuellleg1_1").display = display.hidden;
this.getField("Fuellleg1_2").display = display.hidden;
this.getField("Fuellleg1_3").display = display.visible;
break;
default:
this.getField("Fuellleg1_1").display = display.hidden;
this.getField("Fuellleg1_2").display = display.hidden;
this.getField("Fuellleg1_3").display = display.hidden;
break;
}
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thom/Bernd,
Thanks so much - I would never have been able to come up with that, beautiful! really appreciated, many thanks.
😉
Copy link to clipboard
Copied
While I realize this post is several months old, I recently tried this validation script based on a selection in a combo box where each item has been assigned an export value. As I thought the event.value was assigned an export value different from the text item selected, for whatever reason the validation script doesn't appear to work. However, if I then delete all the export values and use the selected item string name, it works without flaw. Am I missing something here? On another note, it sure would be beneficial if a combo or list box were designed to allow adding an image next to a text item. While the validation script provided is the next best thing to not having this feature, unfortunately, the image doesn't display until the field loses focus. While I have as yet to investigate the possibility, I am wondering if there is a way to create a popup menu to display text alongside an image?
Copy link to clipboard
Copied
Set your combox to "Commit selected item immediately". You'll find this option on the Options tab on the Properties dialog for the combo box field.
https://www.pdfscripting.com/public/Editing-Fields-Properties.cfm
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thanks Tom. I've been away from Acrobat for some years so I am admittedly a little bit rusty. Always know I can count on your expertise when it comes to Questions related to Acrobat. On another note, I had saved an article you authored many years ago on using the popup menu. Not to flatter you but it has to be one of the best if not the best article explaining how to create and implement a popup menu using Javascript. Needless to say, I learned a lot from reading that article the apples, oranges, etc., example comes to mind where I was thinking how amazing it would be if there were some way to create and add the images next to the text. In reality, I am really kind of surprised and disappointed Adobe never came up with a combo box to include such a feature. Your thoughts.
Copy link to clipboard
Copied
There are many things about PDF form fields that could be massively improved. The same thing could be said about the JavaScript model. The two are related. But there are reasons. PDF forms were added many years ago. Expectations were different then. PDF is supposed to be like static paper, not like a dynamic web page. PDF is an ISO spec, so what's defined now takes an act of god to change.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
 
Copy link to clipboard
Copied
 
Football

