Remove spawned page
Hello! I have the code below and it works to populate the page I'm needing called, Users 5 & 6, when the checkbox is marked. However, I'm trying to make it so if the box is unchecked it will then remove that page. It's not working for the removal...
var fld = this.getField("Users 5 & 6");
var ident;
if (fld.value=="On") {
// check to see if there is already a Users 5 & 6 Page
// if there is, don't add it again
var text = "";
var pages = new Array();
for (var i = 0; i < this.numFields; i++) {
if (this.getNthFieldName(i).indexOf("Identity") > -1 ) {
text += "Field[" + i + "] = " + this.getNthFieldName(i);
ident = this.getField(this.getNthFieldName(i));
text += " Page# " + ident.page + "#";
text += " hello " + ident.valueAsString;
if (ident.valueAsString == "Users 5 & 6") {
if (ident.page > -1) {
pages.push(ident.page); }
}
}
}
if (pages.length > 0) {
//remove // in front of app.alert for troubleshooting
//app.alert("already added");
}
else {
var temp = this.getTemplate("Users 5 & 6");
temp.spawn({nPage: this.numPages - 1, bOverlay: false});
}
//remove // in front of app.alert for troubleshooting
//app.alert(text,3);
//remove // in front of app.alert for troubleshooting
//app.alert("leave on");
}
else {
var text = "";
var pages = new Array();
for (var i = 0; i < this.numFields; i++) {
if (this.getNthFieldName(i).indexOf("Identity") > -1 ) {
text += "Field[" + i + "] = " + this.getNthFieldName(i);
ident = this.getField(this.getNthFieldName(i));
text += " Page# " + ident.page + "#";
text += " hello " + ident.valueAsString;
if (ident.valueAsString == "Users 5 & 6") {
if (ident.page > -1) {
pages.push(ident.page); }
}
}
}
for (var p = this.numPages - 1; p > -1; p--) {
if (pages.indexOf(p) > -1) {
//remove // in front of app.alert for troubleshooting
//app.alert(p);
this.deletePages(p);
}
}
//remove // in front of app.alert for troubleshooting
//app.alert(text,3);
//remove // in front of app.alert for troubleshooting
//app.alert("leave off");
}
this.calculateNow();
