Skip to main content
Participant
March 11, 2023
Answered

HELP: Submit button javascript issue

  • March 11, 2023
  • 1 reply
  • 2474 views

Hi, 

 

I'm trying to use the submit button in a form to send an email to 1 of 5 people that are available on drop-down menu - they are only names, so i'm trying to make the script to work like when name from this field is selected, use this email address to send 

Some thing like this below: 

 

Var cTo Addr = this.getField (Dropdown6); 

if value = "X (Name of person)" event.value = "xyz@xyz.com" 

else 

if  (etc....)

 

I can't seem to get it to work, probably my code is wrong. Can someone please help me? 

 

Thank you!! 🙂 

 

 

This topic has been closed for replies.
Correct answer try67

I did as you said and used the email addresses as export values and then adjusted the script as follows: 

var cToAddr = this.getfield ("Dropdown6"); var cCCAddr = email.rawValue; var cSubLine = "Completed & Signed Project Checklist"; var cBody = "Please see completed and signed checklist. Once reviewed, print out a copy and attach to your file.\n" this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: cSubLine, cMsg: cBody});

 

The submit button doesn't seem to do anything though.. Is it still the code that's incorrect or is there something else missing? 

Thanks 🙂 


You still have quite a few errors in it. They should have been reported in the JS Console. Did you check it?

- It's getField, not getfield. JS is case-sensitive!

- To access the value of a field you must use the following syntax:

var cCCAddr = this.getField("email").valueAsString;

- You're missing a semi-colon at the end of the declaration of the cBody variable.

1 reply

try67
Community Expert
Community Expert
March 11, 2023

Yes, it's very wrong. See this tutorial to learn how to achieve that:

https://acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address

 

Participant
March 11, 2023

Thanks for your reply Try67 🙂 

I've reviewed that article a few times, but it doesn't show how I can assign email addresses in the mail.doc script if they don't already exist as a field. 

The field is only names of sales people, which I want to pull and then if name = x then use "xyz@xyz.com" to mail the document. 

Any advice on how I can do this? 

try67
Community Expert
Community Expert
March 11, 2023

Apply the email addresses as the export values of the items in the drop-down and you won't need any if-conditions.