Copy link to clipboard
Copied
I have an existing interactive form that I built on Acrobat DC. It was originally 23 pages and had several custom javascript calculations and hidden/visible fields based off of checkboxes or radio buttons. I'm new to javascript, but after a lot of reading, I had this working really well. However, I needed to add 3 new pages to the document to accomodate some company paperwork changes. I added these 3 pre-built pages right before the last page of the document using the "organize pages" tool. They are not spawned pages. Now, when I try to reference fields on these new pages via javascript it's as if they do not exist. I don't get error messages, but nothing happens either. Additionally, the one pre-existing last page, which follows the new pages, is also behaving badly. Any pre-existing references to the fields on that page work fine, but any new references are acting as if it doesn't exist either. These aren't complex scripts, and I've looked at them a millions times to verify accuracy of naming, etc. For example my validation script on a dropdown on a pre-existing page is this:
if (event.value == "Y")
{
this.getField("cprent").value = "Yes";
this.getField("cpet").value = "Yes";
this.getField("prent").display = display.visible;
this.getField("p_prent").display = display.visible;
}
else
{
this.resetForm("cprent");
this.resetForm("cpet");
this.resetForm("prent");
this.getField("prent").display = display.hidden;
this.getField("p_prent").display = display.hidden;
}
This script works perfectly. Below is the script with the new fields on the new pages added. The existing script continues to work correctly, but nothing happens with the new lines of script.
if (event.value == "Y")
{
this.getField("cprent").value = "Yes";
this.getField("cpet").value = "Yes";
this.getField("prent").display = display.visible;
this.getField("p_prent").display = display.visible;
this.getField("pg_identify").display = display.hidden;
this.getField("pg_animal").display = display.hidden;
}
else
{
this.resetForm("cprent");
this.resetForm("cpet");
this.resetForm("prent");
this.getField("prent").display = display.hidden;
this.getField("p_prent").display = display.hidden;
this.getField("pg_identify").display = display.visible;
this.getField("pg_animal").display = display.visible;
}
This is just one example. Literally none of my references to fields on these new pages are working. Any insight would be super appreciated. I'm making myself crazy!
If getField returns null it means the field can't be located. If you can see it, then it's probably corrupt.
Remove it, save the file under a new name, then close and re-open it and add it again.
Copy link to clipboard
Copied
Assuming "prent" is one of those new fields, what does running this code (from the JS Console) return?
this.getField("prent")
Copy link to clipboard
Copied
Sorry, I should have been more clear, but "prent" is an existing field and it returns "[object Field]" in the JS Console. If I run this.getField("pg_identify") it returns "null". For clarification, the new fields are "pg_identify" and "pg_animal". Interestingly, if I run this.getField("pg_animal") it also returns "[object Field]", but the script behavior doesn't work for this one either. Not sure why there's a difference here since it's the exact same field copied from other pages, but they've all been given unique names. Thanks in advance for your help!
Copy link to clipboard
Copied
If getField returns null it means the field can't be located. If you can see it, then it's probably corrupt.
Remove it, save the file under a new name, then close and re-open it and add it again.
Copy link to clipboard
Copied
That worked perfectly. Thank you!