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

Javascript to submit form, how to formate the body

elo179
Registered: Feb 11 2008
Posts: 2

I am using LiveCycle 8.0, today is my second day at it and I am using the following javascript on a regular button so that when a user fills out a form it auto e-mail me and adds the info to the body in plain txt.

----- form1.#subform[0].Email::click: - (JavaScript, client) ---------------------------------------

event.target.submitForm({cURL:"mailto:me [at] myemail [dot] com?subject="+ID1.rawValue+"'s Hareware Move&body=Do not change subject line or body of this email. User Info: NMCI User ID: "+ID1.rawValue+" Phone: "+phone1.rawValue+" Computer Info: Asset: "+Asset.rawValue+" Computer Name: "+Compname.rawValue+" Current Location: Bldg: "+Bldg1.rawValue+" Floor: "+Floor1.rawValue+" Room: "+Room1.rawValue+" Network plug "+Plug1.rawValue+" New Location: Bldg: "+Bldg2.rawValue+" Floor: "+Floor2.rawValue+" Room: "+Room2.rawValue+" Network Plug: "+Plug2.rawValue+" Comments: "+Comments.rawValue+"",cSubmitAs:"PDF",cCharset:"utf-8"});

This works well, but I would like to edit the body, Because I will get an e-mail with no formating

===============

Body:
Do not change subject line or body of this email. User Info: NMCI User ID: null Phone: null Computer Info: Asset: null Computer Name: null Current Location: Bldg: null Floor: null Room: null Network plug null New Location: Bldg: null Floor: null Room: null Network Plug: null Comments: null

What do I need to do to be able to format the e-mail body so it will look like:

===============
Body:
Do not change subject line or body of this email.
User Info:
NMCI User ID: null
Phone: null
Computer Info:
Asset: null
Computer Name: null
Current Location:
Bldg: null
Floor: null
Room: null
Network plug null
New Location:
Bldg: null
Floor: null
Room: null
Network Plug: null
Comments: null

Thanks in advance

*edit to give better example

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
So you need to add NewLines to the body. NewLines are inserted into a string with the "\n" escape sequence. But of course, you can't put one of these in an URL, at least not directly. They have to be URL encoded.

Start off by defining the body text in a separate variable. Then use the JavaScript "encodeURI" function to URL encode it for transmission. Like this

var myBodyText = "Hello\nWorld";

event.target.submitForm({cURL:"mailto:me [at] myemail [dot] com?body=" + encodeURI(myBodyText) + "&subject=" + ID1.rawValue, ... });

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