Copy link to clipboard
Copied
Hi all,
Can use same help on trying to hide fields on multiple pages that was created from a hidden template page. You would click on the 'ADD PAGE' Button where it has this javascript linked to it.
this.getTemplate("Provider").spawn({nPage:this.numPages, bRename:true, bOverlay: false});
The fields on the hidden template page are prefaced with:
"P0.field_name"
Fields I want to hide are prefaced with:
"P0.Hidden.field_name"
When I click on the add page button, the above fields become prefaced (respectively):
"P#.Provider.P0.field_name"
"P#.Provider.P0.Hidden.field_name"
The # would represent the numbered page. So 'P1' after clicking 'ADD PAGE' button once, 'P2' after clicking 'ADD Page' button a second time.
I would like to now be able to hide all of the "P#.Provider.P0.Hidden" groups when I click on a 'HIDE' Button across all pages, no matter how many were created. The below script is using a hidden check box field to be able to turn on and off the hidden value using the same HIDE button. (just did it this way to test out various things)
var oChkFld = this.getField("HiddenCheck");
oChkFld.checkThisBox(0,!oChkFld.isBoxChecked(0));
this.getField("P#.Provider.P0.Hidden").display = (oChkFld.value=="Off") ? display.hidden : display.visible;
What is the correct way to hide all of those fields across all pages when the # is an unknown?
Thanks!
Mike
I would use something like this:
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
if (/Hidden/.test(f.name)) f.display = display.hidden;
}
Copy link to clipboard
Copied
I would use something like this:
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
if (/Hidden/.test(f.name)) f.display = display.hidden;
}
Copy link to clipboard
Copied
If the page number cannot be predicted reliably, then the thing to do is to search all the field names for those that contain the word "Hidden" or whatever other string uniquely identifies the fields.
// Use an array to collect the target fields
var aHiddenFlds = [];
for(var i=0;i<this.numFields;i++)
{
var strFld = this.getNthFieldName(i);
if(/Hidden/.test(strFld))
aHiddenFlds.push(strFld);
}
Now you have a list of the needed fields
However, say the script is activated from a button (or other field) on the same page as the fields of interest, then the prefix can be acquired from the originating field.
if(/(P\d{1,2}.Provider)/.test(event.targetName))
{
var strPrefix = RegExp.$1;
... code for hiding fields ...
}
Copy link to clipboard
Copied
Thanks to you both! I was able to get it to work. I appreciate the help very much!
Mike