Expand my Community achievements bar.

SOLVED

HTTP Submit Button vs event.target.submitForm

Avatar

Former Community Member

Dear All,

I have a problem that looks like I would need some expert help to resove.

I have designed a small Form with Acrobat LiveCycle Designer ES 8.2

The plan is people to fill out the form and submit it to a script on a web page.

Here is the problem.

When I insert a regular HTTPSubmit button. Everithing is working just fine. All th fields are submited, and I can process them from there with my script.

However, when I try to make a regular button and add javascript to the click event.

event.target.submitForm({cURL: "http://mysite/myscript.php", cSubmitAs:"HTML", cCharSet:"utf-8"});

The form is submited but non of the fields are.

As an example output from REQUEST array in PHP.

With the regular HTTP Submit button I get:

Array
(
    [familyname] => 1
    [SubjectNumber] => 2
    [Site] => 3
)

While with the above javascript I get:

Array
(
    [form1] => Array
        (
            [0] =>
        )

)

Looks like with the Javascript I somehow cannot submit the actuall fields.

Finally, let me tell you the reason why I even want to use Javascript instead of the regular HTTP Submit button.

My plan is so people can actually change the location where to submit the form.

From what I read if I use a regluar submit button, the URL must be hardcoded and cannot be changed (selected, by the user dinamically)

While if I use javascript then I can easily have a text field where people can enter the site where they want to submit the form and use it.

Thank you very much for your help

Please let me know if you need any further information

Regards

Tsvyatko

1 Accepted Solution

Avatar

Correct answer by
Level 6

Actually I think you can set the url for a submit button.  Try using the following FormCalc code:

submitbuttonname.event__click.#submit.#target

= user entered string

The user-entered string needs to include "http://" at the front, e.g. http://www.google.com

As long as the above code is executed before the submit button is pressed you should be OK.  I haven't worked out the syntax for javascript.

View solution in original post

6 Replies

Avatar

Correct answer by
Level 6

Actually I think you can set the url for a submit button.  Try using the following FormCalc code:

submitbuttonname.event__click.#submit.#target

= user entered string

The user-entered string needs to include "http://" at the front, e.g. http://www.google.com

As long as the above code is executed before the submit button is pressed you should be OK.  I haven't worked out the syntax for javascript.

Avatar

Former Community Member

Kevin is right .....the Javascrit equivalent woudl be:

submitbuttonname.event_click.submit.target = URl string

Paul

Avatar

Level 6

There should be two underlines in event__click.  It's hard to see it in the forum posts.

Avatar

Former Community Member

Hey gays, thanks for answering.

However, looks like I still have problems.

When I insert a regluar HTTP submit button, it asks for the URL or it will give error.

Anyhow, if I leave the URL setting blank, and try to execute the code u mentioned, I get a messege, "submit canceled" and nothing is happening,

And if I enter something in the URL, looks like it still overites the code and submits the form the the hard coeded url.

In addition, the regular submit button does not even allow me to enter code in the click even, so I did enterend in the mose in even,

as to execute the code before the button is clicked.

In addition I also tried to enter the even in a text field exit which I was hoping to use so the user can enter their own url.

In other words.

could please be more specific.

On which even shown I enter the code.

p.s.

Finaly,

in Form Calc

If I enter this on the mouse enter of the button:

form1.SCOPA_p2.HTTPSubmitButton1.event__click.#submit.#target = form1.SCOPA_p2.HTTPSubmitButton1_txt.rawValue;

I get error accessor form1.SCOPA_p2.HTTPSubmitButton1.event__click.#submit.#target is unknown

Any other thoughts

Thanks

Tsvyatko

Avatar

Level 6

Check out the attached .pdf.

There is a textbox and an HTTP submit button on the form.  Initially the button sets itself to hidden.  For the text box, after you enter a URL, the exit event it sets the URL of the button to the entered text and makes the button visible.  If you don't enter any text in the box the button will be made invisible again.  There's no need to set a default URL for the button since it will not be enabled unless the user enters a URL.

Somewhere along the line I would add some code to valide the user's text; they must have "http://" in front, and it should end in ".something".

This example was done in javascript.

Avatar

Former Community Member

Hi Guys, thank you very much for the help.

I fianlly made it work ))

Kevin. Thanks a loooooott for sending this file.

Just one think I want to clearify if someone else comes to this post looking for answer.

When I got Kevin's file, it was working perfectely, exactly what I needed. However, when I copied and pasted the text box and the button to my form, it was giving the same problems as before. I was just about to post my own file to you guys to see what is the problem, when I realized that I was saving my form as a [static pdf document].

So Of course, when I saved it as a [dinamic form] everithing is working now.

So the secert was there, I needed to save it as a dinamic document and NOT static.

Thank you all again

Regards

Tsvyatko