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

how to script using the 'submit' object?

JGarn23
Registered: Feb 17 2010
Posts: 35
Answered

can someone show me how to create script using the XFA submit object, so that if I click a button, the javascript on the button is executed and submits my form. I don't want to use the 'in-built' submit type button.

I don't know if you have to create a 'submit' object, or if you 'get one' with the environment.
If you have to create it how is it done? How are the properties set etc?

Any help appreciated. I'm really struggling on this.
Thanks.

Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi JGarn23,

Check these two tutorials from the Learning Center-
http://www.acrobatusers.com/tutorials/2006/submitting_data
http://www.acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
JGarn23
Registered: Feb 17 2010
Posts: 35
Thanks Dimitri.
What I still don't understand though is how to use the 'submit' object defined in the XFA JS reference. This has a couple of properties I'd like to use. At the moment though I can't figure out how to actually use the object in a script i.e. do I need to create it, does it exist already etc. Any other pointers/examples would be greatly appreciated.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The "submit" object in an XFA form is the XML description of the submit action on button. It isn't really so much of a JavaScript object, as it's just a node in the LiveCycle XML (XFA). It is created when you add one of the predefined email or http submit buttons to a form. But you can also create a submit button using a regular button. Look on the Object tab. There are some radio buttons for selecting the button action. This will give you more options than are on the predefined buttons. And you can manipulate the properties of this submit object at design time using the XML view of the form or at runtime with JavaScript by using the XML node functions.

You'll need the XML Form Object Model Reference for the functions and properties of the various XML objects in XFA. You can find it here:
http://partners.adobe.com/public/developer/xml/topic.php

However, if you want the button perform actions other than the submit. For example, some kind of special form level validation, disabling fields, or something else before submission, then you'll need to do a purely JavaScript submit using the "doc.submitForm()" function. As pointed out by Dimitri. The Submit Object describes an action to be performed on a button event. It is not directly executable from JavaScript.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

JGarn23
Registered: Feb 17 2010
Posts: 35
Thom,

You say the submit object isn't really a JS object, just a node in the XFA. Do you say this because 'submit' is derived from the 'event' class, hence it doesn't make sense to create a submit object because it's only created when an event occurs?

When working with XFA how do you distinguish between:
- objects that can be created/manipulated directly? e.g can I create a new instance of all objects in the Form Model class etc
- objects that are created due to events? Are these simply objects derived from the event class or its subclasses?
- objects that you 'get for free' with the environment and you don't have to create?

When I read the JS specs I simply saw the word 'object' and thought, "OK, I can create one of them". It's obvious that I still don't fully understand the XFA model (& I've read the XFA/SOM/JS etc documents more times than I care to think about) but your comments have got me moving in the right direction at last!!!
Thanks.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
For all the documentation, the XFA model isn't all that well documented. For example, nowhere does it say what objects/functions/properties require special enabling for reader. It also doesn't list what's a big no-no and what's not. It's one of those things where you need to play around with it and know what you are doing. There are nodes that you can clone, modify, and re-insert; and there are those that you can't, or shouldn't. There are things that should be modified in the template model, and things that should be modified in the form model. There are things that can be modified, but have no effect. And all these things change with the version of Acrobat and the type of form. These things depend on how the model is hooked into the forms engine. It's possible that some bits are set in stone at load time and cannot be changed. Or that Acrobat will not accecpt certain kinds of model changes at runtime. But none of this is documented. You're on your own.

So, you can in fact create a new event and/or submit object on the fly at runtime. But I don't know how well this will work, you'll have to try it out. But I don't see that there is any reason to do it. It so much easier and more effective to modify an existing object, or just use the JavaScript function, which is documented and pretty much guarenteed to work accross versions, which object modification is not.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script