Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - form submission on required field
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

form submission on required field

 Post Reply Post Reply
Author
turpentyne View Drop Down
New Member
New Member


Joined: 12 Jul 2012
Location: phx
Points: 5
Post Options Post Options   Quote turpentyne Quote  Post ReplyReply Direct Link To This Post Topic: form submission on required field
    Posted: 12 Jul 2012 at 8:00am
I'm just beginning to dabble in adding javascript to pdf forms. I have a simple little script for verifying that 4 fields are not empty. It's applied to a submit button, and works fine. But I don't know how to add the submit part. I just want it to submit the entire pdf via email, if the fields are completed, then load a web page..

Right now I have:

var Phone = this.getField("Phone").value;
var Email = this.getField("Email").value;
var Caliber = this.getField("Caliber").value;
var M = this.getField("Machined-inAluminumPillars").value;

if ((Phone =="") || (Email =="") || (Caliber =="") || (M ==""))
{
app.alert("You must fill in all required fields before submitting.");
T.readonly = false;
F.readonly = false;
} else {app.alert("that worked.");
// here's where I want the submit to happen.
app.launchURL("http://www.x.com/url.php", true);
}
Back to Top
Sponsored Links


Back to Top
aandi View Drop Down
Senior Member
Senior Member


Joined: 07 Jul 2011
Points: 18358
Post Options Post Options   Quote aandi Quote  Post ReplyReply Direct Link To This Post Posted: 12 Jul 2012 at 8:40am

I'd strongly recommend the following:

1. Don't try to submit the whole file, just submit the form fields. Otherwise, it won't work with Adobe Reader unless you jump through extra hoops.
 
2. Don't think of "submitting by email". It is not viable for anything except testing, certain corporate settings, and cases where failure is of little importance (e.g. surveys). Submit to a web site.
Back to Top
turpentyne View Drop Down
New Member
New Member


Joined: 12 Jul 2012
Location: phx
Points: 5
Post Options Post Options   Quote turpentyne Quote  Post ReplyReply Direct Link To This Post Posted: 12 Jul 2012 at 4:21pm
unfortunately, this is what they want.

Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 629
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 14 Jul 2012 at 3:04pm
this.mailDoc() will create a new email with the file attached to it. It's up to the user to actually send the email, though. If the user doesn't send the email this method will throw an exception, which you can then catch and handle. See the reference files for the complete list of parameters that can be used with this method.
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
turpentyne View Drop Down
New Member
New Member


Joined: 12 Jul 2012
Location: phx
Points: 5
Post Options Post Options   Quote turpentyne Quote  Post ReplyReply Direct Link To This Post Posted: 16 Jul 2012 at 11:13pm
I've gotten to this point, based off the this.maildoc(), but now pressing the button seems to do nothing? It's set to run this script on mouseup:

var Phone = this.getField("Phone").value;
var Email = this.getField("Email").value;
var Caliber = this.getField("Caliber").value;
var M = this.getField("Machined-inAluminumPillars").value;

if ((Phone =="") || (Email =="") || (Caliber =="") || (M ==""))
{
app.alert("You must fill in all required fields before submitting.");
T.readonly = false;
F.readonly = false;
} else {

var cToAddr = "info@test1.com";
var cBCCAddr = "info@test2.com";
var cBenAddr = "info@test3.com";

if(cBenAddr != "") {
var cSubLine = "Your McMillan Stock Order Form";
var cBody = "Attached you will find a PDF copy of today's work order notes for your own records. ";

this.mailDoc({bUI: true, cTo: cToAddr, cBcc: cCCAddr,
cSubject: cSubLine, cMsg: cBody});
app.launchURL("http://www.x.com/url.php", true); }
}
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 629
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 16 Jul 2012 at 11:29pm
Check the JS console for errors.
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
turpentyne View Drop Down
New Member
New Member


Joined: 12 Jul 2012
Location: phx
Points: 5
Post Options Post Options   Quote turpentyne Quote  Post ReplyReply Direct Link To This Post Posted: 18 Jul 2012 at 12:29am
Sadly, I'm not sure how. I'm in the javascript debugging console. I can see my script. But I don't know how to run it and get any sort of error reporting.

The first button at the top, the arrow, is greyed out and unclickable.  I click the green button. it just turns red and does nothing.

I turned on "debug from start", then went back and pressed the submit button. All it does is crash acrobat.





Edited by turpentyne - 18 Jul 2012 at 12:35am
Back to Top
aandi View Drop Down
Senior Member
Senior Member


Joined: 07 Jul 2011
Points: 18358
Post Options Post Options   Quote aandi Quote  Post ReplyReply Direct Link To This Post Posted: 18 Jul 2012 at 12:32am
Your script should be run in the usual way e.g. clicking a Submit button. If anything is wrong, the debugging console will say something.
Back to Top
turpentyne View Drop Down
New Member
New Member


Joined: 12 Jul 2012
Location: phx
Points: 5
Post Options Post Options   Quote turpentyne Quote  Post ReplyReply Direct Link To This Post Posted: 18 Jul 2012 at 12:43am
Aha! progress! Thank you!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.047 seconds.