Copy link to clipboard
Copied
I have a group of 15 check boxes, if one of them (or more) is checked, then I would like field to show. If none are checked, the field disappears. How would I do this?
Additionally, if the check boxes and fields are updated (if spawned), how would this work?
Sorry, first line should be:
var baseName = event.target.name.replace("User1_Reporting_Cover", "");
Copy link to clipboard
Copied
The first part is quite simple, but the second part is much more complicated.
Regarding the first: What are the names of those check-boxes, and of the field to show/hide?
Copy link to clipboard
Copied
The names of the check boxes are as follows: "User1_Account1_Reporting", "User1_Account2_Reporting", "User1_Account3_Reporting", "User1_Account4_Reporting", through "User1_Account15_Reporting".
The field is called "User1_Reporting_Cover"
Copy link to clipboard
Copied
OK. You can use this code as the custom calculation script of "User1_Reporting_Cover", then:
var bShow = false;
for (var i=1; i<=15; i++) {
if (this.getField("User1_Account"+i+"_Reporting").valueAsString!="Off") {
bShow = true;
break;
}
}
event.target.display = bShow ? display.visible : display.hidden;
Copy link to clipboard
Copied
Great thanks try67​!
To my other point, upon spawning a new blank template, how would this work to update the field titles?
Copy link to clipboard
Copied
That's much more complicated. You would need to study how the fields are named on spawned pages and then adjust your code to be able to handle that.
Copy link to clipboard
Copied
Can you give me a sample code that I can adjust to?
My code spawns as follows: P3.User_Page1.User1_Wire_Cover
Copy link to clipboard
Copied
Try this:
var baseName = event.target.replace("User1_Reporting_Cover", "");
var bShow = false;
for (var i=1; i<=15; i++) {
if (this.getField(baseName + "User1_Account"+i+"_Reporting").valueAsString!="Off") {
bShow = true;
break;
}
}
event.target.display = bShow ? display.visible : display.hidden;
Copy link to clipboard
Copied
the debugger says that "event.target.replace" is not a function.
Copy link to clipboard
Copied
Sorry, first line should be:
var baseName = event.target.name.replace("User1_Reporting_Cover", "");
Copy link to clipboard
Copied
Great, that worked!! I'm all set for fields, but if one of those fifteen checkboxes were selected (on a spawned page) how would it trigger a checkbox (as you cannot calculate a checkbox)?
Copy link to clipboard
Copied
You can do it using the calculation event of a text field.
Copy link to clipboard
Copied
try67​ - the problem is that the field shows, but the checkboxes do not show.
If one of the 15 checkboxes is clicked, how do additional checkboxes show up? I'm trying to leverage the following code (that will be added to each of the 15 checkboxes):
var aParts = event.targetName.split(".");
aParts.pop();
var cPrefix = aParts.join(".");
for (var i=1; i<=15; i++) {
if (this.getField(cPrefix+".User1_Account"+i+"_Wire").valueAsString!="Yes")
{
this.getField(cPrefix+".User1_Wire_Create").display = 0;
this.getField(cPrefix+".User1_Wire_OneTime").display = 0;
this.getField(cPrefix+".User1_IFT_Approval").display = 0;
this.getField(cPrefix+".User1_Wire_FileImport").display = 0;
this.getField(cPrefix+".User1_Wire_TemplateImport").display = 0;
this.getField(cPrefix+".User1_Wire_ReleaseCancel").display = 0;
this.getField(cPrefix+".User1_Wire_TemplatePayees").display = 0;
this.getField(cPrefix+".User1_Wire_ActivityAudit").display = 0;
this.getField(cPrefix+".User1_Wire_TemplateMaintenance").display = 0;
this.getField(cPrefix+".User1_Wire_ApprovalRelease").display = 0;
this.getField(cPrefix+".User1_Wire_Daily Transaction Debit Amount Per Account").display = 0;
this.getField(cPrefix+".User1_Wire_Daily Transaction Count Per Account").display = 0;
this.getField(cPrefix+".User1_Wire_Single Transaction Debit Amount").display = 0;
this.getField(cPrefix+".User1_Wire_DefaultCover").display = 1;
this.getField(cPrefix+".User1_Wire_NoApprovers").display = 0;
this.getField(cPrefix+".User1_Wire_OneApprover").display = 0;
this.getField(cPrefix+".User1_Wire_OneApprover_Amount").display = 0;
this.getField(cPrefix+".User1_Wire_TwoApprover").display = 0;
this.getField(cPrefix+".User1_Wire_TwoApprover_Amount").display = 0;
}
else
{
this.getField(cPrefix+".User1_Wire_Create").display = 1;
this.getField(cPrefix+".User1_Wire_OneTime").display = 1;
this.getField(cPrefix+".User1_IFT_Approval").display = 1;
this.getField(cPrefix+".User1_Wire_FileImport").display = 1;
this.getField(cPrefix+".User1_Wire_TemplateImport").display = 1;
this.getField(cPrefix+".User1_Wire_ReleaseCancel").display = 1;
this.getField(cPrefix+".User1_Wire_TemplatePayees").display = 1;
this.getField(cPrefix+".User1_Wire_ActivityAudit").display = 1;
this.getField(cPrefix+".User1_Wire_TemplateMaintenance").display = 1;
this.getField(cPrefix+".User1_Wire_ApprovalRelease").display = 1;
this.getField(cPrefix+".User1_Wire_Daily Transaction Debit Amount Per Account").display = 1;
this.getField(cPrefix+".User1_Wire_Daily Transaction Count Per Account").display = 1;
this.getField(cPrefix+".User1_Wire_Single Transaction Debit Amount").display = 1;
this.getField(cPrefix+".User1_Wire_DefaultCover").display = 1;
this.getField(cPrefix+".User1_Wire_NoApprovers").display = 1;
this.getField(cPrefix+".User1_Wire_OneApprover").display = 1;
this.getField(cPrefix+".User1_Wire_OneApprover_Amount").display = 1;
this.getField(cPrefix+".User1_Wire_TwoApprover").display = 1;
this.getField(cPrefix+".User1_Wire_TwoApprover_Amount").display = 1;
}
}
Any help is greatly appreciated!
Copy link to clipboard
Copied
There's really no need to place the code on each one of the check-boxes. Just use the calculation script of a (hidden) text field.
Also, I believe this code you found is for a spawned page. You don't need that. Just use the names of the fields directly.
Copy link to clipboard
Copied
Ok - what would the code look like?
Copy link to clipboard
Copied
Sorry, I went back and I do see that you want to do it as a part of spawned page. In that case just put the code you have as the custom calculation script of a text field (that is located on the Template page) and I think it should work.
Copy link to clipboard
Copied
Unfortunately the check boxes do not disappear when I do this.
Copy link to clipboard
Copied
Are there any errors in the JS Console? Can you share the file in question?
Copy link to clipboard
Copied
what is your email? I will send the form. I your scroll down to the user set up, as you can see the checkboxes are not disappearing when needed (for wires), I would like this to do this for all the subsequent sections and when this is spawned over and over again.
Copy link to clipboard
Copied
You can send it to [try6767 at gmail.com].