Copy link to clipboard
Copied
Hi there,
I would like to know if anyone has found javascript that would find a specific form text field name and then delete the page it is on?
I am working on a form that new pages will be added if the client uses a dropdown to select number of accounts and the template spawns from that. But I would like to give the client the opportunity to change the number of spawn pages if they have got it wrong. Complete novice to this. I did the original with show hide javascript but the client has asked for the pages to delete.
Copy link to clipboard
Copied
You can use 'page' property to find page number of a specific field, for example let's say you want to delete page where "Text1" field is located:
var f = this.getField("Text1").page;
this.deletePages(f);
Copy link to clipboard
Copied
You can use 'page' property to find page number of a specific field, for example let's say you want to delete page where "Text1" field is located:
var f = this.getField("Text1").page;
this.deletePages(f);
Copy link to clipboard
Copied
Just be aware this will only work if there's only one copy of the field. If there are more copies of it, even on the same page, the page property will return an array, not a number!
Copy link to clipboard
Copied
PS. Also, you need to check if the page number is not -1, or you could accidentally delete the Template page (or it will produce an error).
Copy link to clipboard
Copied
Hi Nesa,
Thanks for your help. I have added the code to a Combo Box in the calculate script custom calculation area.
var v = this.getField("Combo Box 1").value; if (v === “two”) { var f = this.getField("Text 2").page; this.deletePages(f); } if (v=== "three"){ var g = this.getField("Text 3").page; this.deletePages(g); }
But it doesn't seem to be working.
Have I done something wrong
Copy link to clipboard
Copied
There are errors in your code. Check the JS Console. You must always use straight quotes, not curly ones.
Copy link to clipboard
Copied
Many thanks, now working
Copy link to clipboard
Copied
Are you able to share how you got this working? I'm working on a similar issue and keep getting errors.
Copy link to clipboard
Copied
It started working after I changed the typographers qupotes to regular quotes.