I have a form that will require several fields to be hidden when the user first loads the form. I would like to automate that with a JavaScript loop where if the object name starts with "hid" set its presence to "hidden".
I found the script below in the LiveCycle ES4's documentation but it does nothing. No errors were reported in the JS console. Which event should the loop be added to? Of the parent form? Is the syntax correct for what I am trying to achieve?
for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++) {
var oFields = xfa.layout.pageContent(nPageCount, "field");
var nNodesLength = oFields.length;
for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {
if (oFields.item(nNodeCount).name.substring(0,3) == "hid") {
oFields.item(nNodeCount).name.presence = "hidden"
}
}
}
Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
On line 8 you need to remove the "name.", the presence is a property of the field, not the name. So;
oFields.item(nNodeCount).presence = "hidden"
You could put this code in the top subforms docReady event, or maybe it would be better in a macro, so that the fields are hidden at design time?
Regards
Bruce
Views
Replies
Total Likes
Hi,
On line 8 you need to remove the "name.", the presence is a property of the field, not the name. So;
oFields.item(nNodeCount).presence = "hidden"
You could put this code in the top subforms docReady event, or maybe it would be better in a macro, so that the fields are hidden at design time?
Regards
Bruce
Views
Replies
Total Likes
Thank Bruce. It works great now!
I want to be able to see the fields in Design view so I am fine leaving the action at the docReady event.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies