Copy link to clipboard
Copied
Can someone tell me how to combine these three scripts so they will function as one? Each script functions but I'd like to have them work like this, the alignment would be set to left when Item.1 is visible and return to align center when hidden.
First script:
var f = this.getField("Item.1");
f.display = (f.valueAsString=="") ? display.hidden : display.visible;
Second script:
var f = this.getField("Item.1");
f.alignment = "center";
Third script:
var f = this.getField("Item.1");
f.alignment = "left";
Is this possible? Thank you.
You will have to fill in the missing parts 0 where Bernd used ... to indicate that something is missing. Based on your description, this should work:
var f = this.getField("Item.1");
if (f.valueAsString == "") {
f.display = display.hidden;
f.alignment = "center";
} else {
f.display = display.visible;
f.alignment = "left";
}
Copy link to clipboard
Copied
Why want you set the alignment to center when the field is not visible and empty?
Copy link to clipboard
Copied
Little difficult to explain. The easiest explanation is, I have other button to show/hide those fields. Do you know how to combine the scripts as I requested in my post?
Copy link to clipboard
Copied
Something like this:
var f = this.getField("Item.1");
if (f.valueAsString=="") {
...
} else {
...
}
Copy link to clipboard
Copied
Hello Bernd, thanks for the reply with the script, but sorry to say I keep getting "Syntax Error" and I'm not so experienced with javascript to figure it out. Or, how to modify the code.
Copy link to clipboard
Copied
What code do you use?
Copy link to clipboard
Copied
You will have to fill in the missing parts 0 where Bernd used ... to indicate that something is missing. Based on your description, this should work:
var f = this.getField("Item.1");
if (f.valueAsString == "") {
f.display = display.hidden;
f.alignment = "center";
} else {
f.display = display.visible;
f.alignment = "left";
}
Copy link to clipboard
Copied
Thank you, Mr Kremer, I examined the code and I learned a bit from it.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now