Skip to main content
Participant
December 1, 2020
Question

Is my submit button's Javascript too long?

  • December 1, 2020
  • 1 reply
  • 340 views

Not too long ago, I posted a question here about submitting form fields in a PDF, without sending the whole PDF (there are two forms on this document and each has its own submit button.) I correctly guessed that the following method would be the only way:

-Use JavaScript to construct an email, and populate the body of the email using the form fields.

 

Finding the right commands wasn't too hard. This script works just fine:

this.submitForm(
    "mailto:msanders2657@gmail.com?"  + 
    "&subject=good news" + "&body=" + 
"Name: " + this.getField("SellerFirstName").value + " " + this.getField("SellerLastName").value +
"\nEmail Address: " + this.getField("SellerEmail").value +
"\nPhone Number: " + this.getField("SellerPhone").value
);

This will construct an email with the body in this format:
Name: Jane Doe
Email Address: janedoe@example.com
Phone Number: (555)555-5555

 

However, the following updated script causes my Submit button to do nothing at all:

this.submitForm(
    "mailto:msanders2657@gmail.com?"  + 
    "&subject=good news" + "&body=" + 
"Name: " + this.getField("SellerFirstName").value + " " + this.getField("SellerLastName").value +
"\nEmail Address: " + this.getField("SellerEmail").value +
"\nPhone Number: " + this.getField("SellerPhone").value +
"\nBest Time to Contact: " + this.getField("SellerContactTime").value
);

 

All I'm doing here is adding another one of the fields to be listed. There are about 20 fields total, but it seems like this script completely breaks if I attempt to send more than four. Can someone tell me what I'm doing wrong here?

 

 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
December 1, 2020