These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Javascript not executing when the adobe form is first opened

dasmits
Registered: Jan 29 2010
Posts: 19
Answered

I have some simple field formatting calls inside my form fields. its a two page form. all of the formatting seems to work just fine on the second page of the form. the first page does not get properly formatted until I physically scroll all the way down to the second page. then when I scroll back up to the first page, POOF!, all of the fields are formatted properly.
 
I created this form in adobe 9. Any assistance from the group would be greatly appreciated. I'm pretty sure my users will not accept 'just scroll down and then scroll up again' :-)

My Product Information:
Acrobat Pro 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Can you post a sample somewhere? Where did you place the code, exactly?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Exactly where are the formatting scripts located?

Only Acrobat Professional lets you create a document level script. In the Standard version you can simulate the document level using the "Page Open" action, but you need to be sure that the page on which the script is located will always be the page the document is opened on.

George Kaiser

dasmits
Registered: Jan 29 2010
Posts: 19
the formatting scripts are on both pages 1 and 2. they are very basic. one example is where I have to strip the time stamp off of the patient DOB:

inside of a field named CASE014[0] I have the following code in the custom calc property:
var dob1 = event.value;
if(event.value != null)
{
event.value = dob1.split (" ").shift();
}


dasmits
Registered: Jan 29 2010
Posts: 19
oh and to George, this form was developed using professional
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
A calculate script is triggered when a field value changes. Is that the entire script?
dasmits
Registered: Jan 29 2010
Posts: 19
yes, thats the entire script. these values are being fed from a sql db. have either of you heard of this type of behaviour before? Im stupmed!
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
I think that script should be changed to a Validate script, and change it to:


if (event.value) {
event.value = event.value.split(" ").shift();
}


It's hard to tell what's going on with the others without looking at the form or you post more code that you're using.
dasmits
Registered: Jan 29 2010
Posts: 19
is there a way to put the entire form here?
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Not here, but you can at Acrobat.com if you create an account.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You can open a free account at www.Acrobat.com and share a file that is uploaded there

George Kaiser

dasmits
Registered: Jan 29 2010
Posts: 19
OK I have an account now and I've uploaded the form. document name is Gwinnett Charity.pdf. not sure who to share it out with though :-(
dasmits
Registered: Jan 29 2010
Posts: 19
ok, I published the file. here is the link
https://acrobat.com/#d=PUzB7vqhsrAQN8NGbq6Qrg
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
You have a Page Open action on page 2 that causes the form to calculate when it it opened. That's why the scripts are executing then. I'm getting a lot of run-time errors.

How exactly are you populating the fields with data and saving the filled-in form?
dasmits
Registered: Jan 29 2010
Posts: 19
Hi George, sorry I missed your response yesterday. 'some' of the form data comes from sql tables, the rest is filled out manually by the end user. at this time, we are not saving the forms, the user just prints it out and has the patient sign them. I'm working on the save function but its challenging since I'm so new to implementing this.

How can I see this 'Page open' action? is it in the document properties section?
Thanks,
Earle
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Open the Pages navigation pane, select the second page, right-click, and select Properties, then the Actions tab.

There are some significant problems with the scripting that are a bit too involved to discuss here. If you'd like help off-line, feel free to contact me.
dasmits
Registered: Jan 29 2010
Posts: 19
Thanks for your help George. I found out how to set a new page open action probably moments before you posted this! yeah, my scripts suck huh? I know, I've been looking in different resources for ways to optimize my code. my biggest challenges to date are around formatting, calculations, and layering fields (hiding and showing data fields based on the value inside of a different field). I'm not a developer , I'm an implementation guy so unfortunately when I get it to work, I'm off to the next fire :-)

I am totally stoked that you'd be willing to help me get this form working more efficiently, how do I contact you off-line?
Thanks so much,
Earle
earle [dot] smith [at] gmail [dot] com