Skip to main content
ctoddjones17
New Participant
November 30, 2017
Answered

Send form to different email addresses depending on dropdown choice?

  • November 30, 2017
  • 2 replies
  • 5642 views

I have a form which needs to be send via a submit button to specific email addresses which are determined by what the user chooses. There are two dropdown boxes which will determine the location i.e.

Dropdown1 choice: London

Dropdown2 choice: Electrical

This will send it to the London Office Electrical Team

Another example

Dropdown1 choice: Bristol

Dropdown2 choice: Construction

This will send to the Bristol office construction team.

There are 6 options in Dropdown1 and 4 options in Dropdown2

I am using javascript in Adobe Pro DC. Tried using switch statements but just cant get it to work.

This topic has been closed for replies.
Correct answer Thom Parker

Do you have emails addresses for all of the different combinations?  The trick is to organize them into a data structure where the two choices automatically select for the correct email.

For Example:

var emailList = {"London":{"Electrical":"LEle@something.com","Construction":"LCon@something.com"},

                         ""Bristol":{"Electrical":"BEle@something.com","Construction":"BCon@something.com"}

}

Then email selection is just a matter of selecting from the list.

var email = emailList[ this.getField("DropDown1") ][ this.getField("DropDown1") ];

2 replies

New Participant
February 7, 2023

I have a form with a drop down list.
there are 3 Options to choose.

each option in the dropdown list has it's own email address. I have entered the email addresses into the export values in the dropdown list.
Based on the choice the user selects from the drop-down list, when they click on “send Button” in the form, the corresponding email address is selected automatically with the form attached. That is the script I used:

var email = this.getField("Dropdown1").value;

this.mailForm(true, email);

 

but now the email will be created without a subject and cc. Id like to add these too.

Can someone help how do I do this?

Thank you!

 

Thom Parker
Community Expert
February 7, 2023
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Thom ParkerCorrect answer
Community Expert
November 30, 2017

Do you have emails addresses for all of the different combinations?  The trick is to organize them into a data structure where the two choices automatically select for the correct email.

For Example:

var emailList = {"London":{"Electrical":"LEle@something.com","Construction":"LCon@something.com"},

                         ""Bristol":{"Electrical":"BEle@something.com","Construction":"BCon@something.com"}

}

Then email selection is just a matter of selecting from the list.

var email = emailList[ this.getField("DropDown1") ][ this.getField("DropDown1") ];

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
New Participant
December 18, 2019

Hello, I saw your reply to this request to control multiple email option functionality based on the particular selection from a dropdown field.  I know this was some 2 years ago but I was hoping you can still assist me.
My issue is i'm not greatly gifted in the world of Javascript but my dilema is similar to ctoddjones enquiry.
Except mine is a little more simpler... I have one dropdown selection field, in which there are 8 location options to select. I require an email address assigned to each individual location selection within this dropdown area. 
Ideally I need step by step help as to how I go about implementing the javascript to achieve this functionality eg. open form > go to 'more tools' > select javascript under customise (I work on a Mac) > insert javascript etc etc.
Can you assist me with this request?

New Participant
August 9, 2023

The easiest way would be to set the email address as the "export value" of each one of the items in your drop-down.

Then you could use a simple could like this to mail the document to the selected address:

 

var targetEmail = this.getField("Office").valueAsString;

this.mailDoc({cTo: targetEmail, cSubject: "Here's the file!", cMsg: "Thank you"});


Hi, Not sure if you'll get this message as this thread is very old, but I have a similar problem. I have 2 Dropdown options and need to assign an email address to each of them. I have added the addresses as the export value but when I try the script above and click my submit button nothing happens.

I wondered if you could assist me as I'm still useless at this.