This seems straightforward but I have yet to find a clear answer to this.
I have a dropdown box with global binding in a Master Page. I would like a separate button, located in the design content area (not the Master Page), when clicked, to tell any instances of the dropdown box in the Master Page(s) to hide, or be visible, etc.
In the SOM editor, the dropdown box tells me its hierarchy is:
form1.MasterPages.Page1.Header.projectSize
In the button's JavaScript on Click I've tried:
xfa.resolveNodes("form1.MasterPages.Page1[*].Header.projectSize").presence="hidden";
and
var nodes = form1.MasterPages.resolveNodes("Page1[*].Header");
var len = nodes.length;
for(var i = 0; i < len; i++) {
nodes.item(i).projectSize.presence="hidden";
}
and a similar script with an xfa.resolveNodes("
before form1.Master...
, all of which do not work.
Is it possible to target Master Page elements, and if so, what would be the correct syntax?
Thank you in advance.
So upon closer inspection, the var nodes method actually works. But it only works when the button is clicked a second time. The other scripts that are run when the button is clicked work fine, but the Master Page dropdown only "hides" when the button is clicked again... Apparently this is the issue now.
I've figured out my problem. Not sure if this can help anyone else, but here is my solution, though I don't completely understand why it works.
To target the dropdown element on every potential iteration of the Master Page, and then to hide each iteration, this JavaScript works in a button located in the document body (I believe it is the same as I initially stated):
var nodes = form1.MasterPages.resolveNodes("Page1[*].Header");
var len = nodes.length;
for (var i = 0; i < len; i++){
nodes.item(i).projectSize.presence="hidden";
}
Upon tearing apart the other scripts that ran along side of this one, I found that another table, and the script I was using to hide it with, was the reason the Master Page dropdown element needed two clicks to run properly.
The culprit table is called notesTable
and is located in a subform called GrandTotals
. The following script worked fine with the other scripts, but failed once the Master Page referencing script came into play: GrandTotals.notesTable.presence="hidden";
The workaround I found to make everything work together on the first click was to reference each cell item within notesTable
and hide them independently:
form1.GrandTotals.notesTable.HeaderRow.notesHeader.presence="hidden";
form1.GrandTotals.notesTable.Row1.notes.presence="hidden";
I only had 2 cells to target so it wasn't a huge deal, but I can imagine this solution turning messy with many rows and cells, etc. Either way, a redundant, longer, hack fix is still a fix.
I am still unsure of why this problem arose, and why this solves it. I had some other problems with other referencing JavaScripts that weren't "specific" enough and had to be changed to reference more redundantly specific bits of the hierarchy to work correctly. These problems weren't happening a week ago, and now they have been a major road block. I'm thinking it might have something to do with some sort of PDF / Reader background update, but I can't be sure.
ANYWAY, here is a random fix to a random issue, but it might clear up some troubleshooting for someone else with a similar confusion.