Copy link to clipboard
Copied
This is not clear in the Javascript document, but where can I put shared functions which are used by my scripts?
Below I have 3 functions. X() and Z() which should both happen on the blur of a text field.
Function Y() is a calculation which both X() and Z() need to use.
Y is available for X(), but not for Z() without pasting its code twice.
Where do shared functions go?
//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------
//<AcroForm>
//<ACRO_source>CN1:Annot1:OnBlur:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:CN1:Annot1:OnBlur:Action1 ***********/
function X()
{
int x = 0;
//do something
int y = Y(); //Works here
return x;
}
function Y()
{
int y = 1;
//do something
return Y;
}
//</ACRO_script>
//</AcroForm>
//<AcroForm>
//<ACRO_source>CN2:Annot1:OnBlur:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:CN2:Annot1:OnBlur:Action1 ***********/
function Z()
{
int Z = 2;
//do something
int y = Y(); //Function Y is out of scope/unavailable here
return Z;
}
//</ACRO_script>
//</AcroForm>
Copy link to clipboard
Copied
As doc-level scripts, under Tools - JavaScript - Document JavaScripts.
And do NOT edit the code via the Edit All JavaScripts command!
Copy link to clipboard
Copied
Ok??? so I added a document level script, and now all my onblur scripts are missing?
What the heck?
They still function but the All Javascripts only shows my document level script now, where are my actions??
Copy link to clipboard
Copied
Did you edit the code using Edit All Javascripts at any point?
Copy link to clipboard
Copied
I've been editing the code using the all scripts for the last year, havent had a problem until I added this document level script.
I have a form with 60 fields each with their on blur script. Moving between each textbox to edit the script with a thousand menu clicks is absurd. How else would I do this?
Copy link to clipboard
Copied
It's possible the file got corrupted because of that. If so, there's no easy way to fix it.
If you have a n earlier version of it saved, revert to it and apply the scripts differently this time around.
That can also be done using a script, instead of manually.