• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

HELP: Submit button javascript issue

Community Beginner ,
Mar 11, 2023 Mar 11, 2023

Copy link to clipboard

Copied

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!! 🙂 

 

 

TOPICS
JavaScript , PDF forms

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 4 Correct answers

Community Expert , Mar 11, 2023 Mar 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

 

Votes

Translate

Translate
Community Beginner , Mar 11, 2023 Mar 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? 

Votes

Translate

Translate
Community Expert , Mar 11, 2023 Mar 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.

Votes

Translate

Translate
Community Expert , Mar 13, 2023 Mar 13, 2023

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.

Votes

Translate

Translate
Community Expert ,
Mar 11, 2023 Mar 11, 2023

Copy link to clipboard

Copied

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

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 11, 2023 Mar 11, 2023

Copy link to clipboard

Copied

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? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 11, 2023 Mar 11, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 11, 2023 Mar 11, 2023

Copy link to clipboard

Copied

Appreciate the help 🙂 Is there a way to do it where the drop-down just stays as name values and the email address is part of the script? 

 

like if user selects "John" then the script applies "john@xyz.com" 

if user selects "Tony" script applies "tony@xyz.com" 

Without having to put these values into any form fields? 

 

Really appreciate your help 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 11, 2023 Mar 11, 2023

Copy link to clipboard

Copied

Sorry, I see what you meant. 

I'll try this and report back. 

 

Thanks! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 12, 2023 Mar 12, 2023

Copy link to clipboard

Copied

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 🙂 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2023 Mar 13, 2023

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines