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

Fillable Text Field to Populate Email Subject Header

nefrsm32
Registered: Aug 11 2009
Posts: 8
Answered

I have reviewed forum examples and am having difficulty with this issue. I am using Acrobat 9 Pro and “Extending Features in Adobe Reader”. The user would fill out the form and then submit the completed form as a pdf document attachment to an e-mail address. I would like the Subject Header populated with a user-completed text field labeled “Item Number”.

I am trying to use the following in a Mouse Up JavaScript in a submit button and the JS Editor gives a message “missing ) after argument list 2: at line 3…Ln 4, Col 4”

var b = this.getField("subject");
this.submitForm("mailto:Name [at] Company [dot] com?"
+ "&subject=" + encodeURI(b.value)
);

I would appreciate your help.

suewhitehead
Registered: Jun 3 2008
Posts: 232
This is how I did mine for a similar situation. You can leave out the app.alert part if you don't need it.

var address = user [at] somewhere [dot] com
var sub = this.getField("ItemNumber").value;
var msgBody = "Attached is the Return Authorization form.";

////message box with instructions to add email addresses
var cResponse = app.alert({
cMsg: "To email this form, select email addresses from the EMAIL FORM TO list. Hold CTRL to select multiple addresses. \n\nYou will be able to add other email addresses after you click YES.\n\nProceed?\n\nClick YES to proceed.\nClick NO to go back and select addresses.",
nIcon: 2, nType: 2,
cTitle: "Email Form"});
// proceed only if response is "YES"
if (cResponse == 4) {

this.mailDoc({
bUI: false,
cTo: address,
cSubject: sub,
cMsg: msgBody,
cSubmitAs: "PDF"
});
}

By the way, I have noticed that when you get the "missing )" error, it usually means that you left out something and that omission is causing the javascript to be interpreted incorrectly. So check all your, commas, quotation marks, parenthesis, and the like.
nefrsm32
Registered: Aug 11 2009
Posts: 8
suewhitehead wrote:
This is how I did mine for a similar situation. You can leave out the app.alert part if you don't need it.var address = user [at] somewhere [dot] com
var sub = this.getField("ItemNumber").value;
var msgBody = "Attached is the Return Authorization form.";

////message box with instructions to add email addresses
var cResponse = app.alert({
cMsg: "To email this form, select email addresses from the EMAIL FORM TO list. Hold CTRL to select multiple addresses. \n\nYou will be able to add other email addresses after you click YES.\n\nProceed?\n\nClick YES to proceed.\nClick NO to go back and select addresses.",
nIcon: 2, nType: 2,
cTitle: "Email Form"});
// proceed only if response is "YES"
if (cResponse == 4) {

this.mailDoc({
bUI: false,
cTo: address,
cSubject: sub,
cMsg: msgBody,
cSubmitAs: "PDF"
});
}

By the way, I have noticed that when you get the "missing )" error, it usually means that you left out something and that omission is causing the javascript to be interpreted incorrectly. So check all your, commas, quotation marks, parenthesis, and the like.
_____________________________________________________

I tried using the script but I get a warning in the JavaScript editor "missing ; before statement 1: at line 2" even after adding a semicolon at the end of line 1.

Still in early stages of learning JavaScript.
suewhitehead
Registered: Jun 3 2008
Posts: 232
Sorry, I forgot " marks. Change this line:

var address = "user [at] somewhere [dot] com"I have tested it and it works.
nefrsm32
Registered: Aug 11 2009
Posts: 8
suewhitehead wrote:
Sorry, I forgot " marks. Change this line:var address = "user [at] somewhere [dot] com"I have tested it and it works.
Yes this works. Thanks so much for your help!

I may have clicked in error on the the "Accept Answer" button for your previous response so the "Accept Answer" for your corrected response appears to be not functional.