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

Submitting data in a LiveCycle form

debayan
Registered: Apr 25 2008
Posts: 7

Hi All,

What I am trying to do is create SAVE button in
the form that will save the changed form into a database. Off-late I was
using Acrobat Pro 8.0 to do all the forms and prefilling. The javascript
that ran behind the SAVE button was:

function submit()
{
var url = this.URL;
var pieces = url.split("/");
pieces[pieces.length-1] = "save.php";
url = pieces.join("/");

this.submitForm(
{cURL: url,
bCanonical: true,
cSubmitAs: "HTML"}
);
}

I want to achieve the same functionality in LiveCycle forms also. Can you
help me with this?

Thanks a lot,

Debayan Bhattacharya

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Only one change is needed. In AcroForms, "this" refers to the document object, but in LiveCycle forms "this" refers to element that the script is attached to. So you cannot use "this.submitForm" in a LiveCycle script. Instead, use

event.target.submitForm(...);

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

sankett
Registered: May 2 2008
Posts: 9
Hi Thom,
Thanks for your reply but this doesn't seem to work. In fact in lifecycle we have a very small set of properties and functions, they do not include anything like submitForm().
One thing which makes me think...

In acrobat professional,
1. We can add actions by selecting properties on a button.
2. We can add javascript as well as "submit a form".

In adobe lifecycle,
1. we can only choose a control type for a button: regular, execute, submit.
2. We can not expect the submit and javascript to work together.

Is there anything I am missing?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Nearly the entire Acrobat JavaScript Model is available to scripting in a LiveCycle document.

Do not use the submit button. Instead, use a regular button and add you code to the "Click" event.

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

sankett
Registered: May 2 2008
Posts: 9
Hey Thomp,
OK got it. I did that. In save.php I just printed the post variable:
print_r($_POST)... this is what I get:
Array ( [form1] => Array ( [0] => ) )I am actually expecting a huge Array with all the variables on this form and their current values but the output is absolutely small.
Can you please let me know if there needs to be any more change.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The field names on a LiveCycle form are referenced in a very different way than on an AcroForm. Amoung other things, LiveCycle likes to use unicode. I don't know if this is the issue, but try setting the "cCharset" to "utf-8". Also, for testing purposes, start out whith just a couple of fields on the form. Other than that I'm at a loss. I've done this before and it worked for me.

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

sankett
Registered: May 2 2008
Posts: 9
Hey Thom,
I tried your suggestion too but couldn't get it to working. I still have 2 forms:
1 with javascript code on click event.
2. with submit type button with direct url.
They produce different $_POST arrays.
I will look ahead to find my way, but thanks for your time and help.