Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need JavaScript code to send PDF form to email with recipient

Status
Not open for further replies.

can123

Technical User
Oct 24, 2002
7
US
I have developed a PDF form which users fill out and I would like to have them be able to hit a "submit" button and the form will be sent via email to an outlook adress. I can get the document to send by using the mailto: function. But I wanted to have the subject line of the note prefill with the contents of one of the text boxes on the form. If anybody could give me a tip, that would be great. Thanks.
 
I have a script which does this, and a little bit more. Here it is:

var name1 = this.getField("Process");
var name2 = this.getField("Systems");
var name3 = this.getField("Engineering");
var num1 = this.getField("Plant Change PC");
var num2 = this.getField("PC Number");
this.mailForm(true, (name1.value + name2.value + name3.value), "", "", (num1.value + num2.value),"The above Plant Change has been developed and requires Technical and Safety Evaluation");

The recipients are populated automatically first, then the subject line is made up of the two field values assigned to num1 and num2, and finally the email body is a fixed string. Hope this helps.


 
Hi,

Thanks for your response. I still dont quite have it though. I need it a bit simpler. Here is what I am trying to use, but it keeps telling me that num1 has no properties...


var name1 = this.getField("address@domain.com");
var num1 = this.getField("Customer Name");

this.mailForm(true, (name1.value),(num1.value),"The above Plant Change has been developed and requires Technical and Safety Evaluation");

Help!!!!

[sunshine] Thanks!


 
Is the syntax of your field "Customer Name" absolutely correct? If num1 has no properties, it's because the script can't determine what num1 is.
 
Ok, I have it, and it is working now. Now how do I get a message to appear after they hit the button, saying Thank you. Your request is being processed?

THANKS!
 
It all depends on what you want the message to look like. On my form, the submit button that called the email script is hidden, and a different read only button is made visible in its place - my button has a tick icon and text "Thank you, your request has been registered".

Just a few other things
- my script also has a saveAs function which saves the form under a new filename first, before the email is sent.
- this.mailForm only sends the FDF, not the whole form
- if you use this.mailForm(true,..... the user will have to click send on the email which is generated. If you want this mail sent automatically you need to use this.mailForm(false,....
 
Murgle - you rock! That is a great idea about the read only button. How would I make the text appear after the hidden button is pushed?

Also, how do I get the save as command?

And (one more question!) We are having trouble opeing the FDF that is sent after hitting submit. Is there any way that we can send it as a PDF? For example, use the save as to send the info as a PFD?

Thanks a lot - you have been a great help!
 
As far as the submit button is concerned, it should initially be visible (obviously, otherwise you wouldn't be able to click on it. To make the button change, you should add the following show/hide field actions to the 'mouse up' action on the button:
- a hide field action on the current button field
- a show field action on the 'message' button (this button should have been created as a hidden field).

The next bit is more complex - if you want to send the whole PDF, then you need to substitute
Code:
this.mailDoc
for
Code:
this.mailForm
- the problem with this is that before it mails the doc, it saves its current version. Where does the user access the original form? Is it a copy of the original which has been sent to them, or is the original master document accessed via a LAN (I'm assuming it's not web based)?
 
Actually, it is posted to an Intranet web site... would it work for that?
 
Is there a particular reason why you want to use email rather than submitting the form to a url?
Is the user viewing the form with Acrobat Reader or full?
I am not a 'Web Head', my experience with Acrobat goes as far as LANs, so I would suggest a visit to Adobe on the web might help here, in particular;

If you definately want to use mail, then give it a go, but I don't know if the method I described will work or not.

Good luck!!
 
Most of them only have reader... And we dont have a URL for them to submit it to. Maybe we could get something set up for them to send it to a URL. I found the site you provided about Using Acrobat Forms and Form Data on the Web particularly helpful.


Thanks again!
 
Just going back to the 'message box' question - you could use the
Code:
app.alert
method, like this..

Code:
app.alert("Thank you , your request is being processed", 3, 0);

This will give you an information box with your message, and an OK button which closes the alert box. If necessary, you could have another script to close the document after the OK button is pressed..

Code:
this.closeDoc(true);

Hope this helps.

Ahhhhh, I see you have a machine that goes Bing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top