I created a form that will be submitted to certain different email addresses based on an option selected from a drop-down list (named Customer).
I tried another script posted here, but that was based on the assumption that there was only one choice per email address in the list.
I wrote this on the change event of my list. I want the variable "emailAddress" to adopt the correct email address, based on the value of the option selected from the list:
var emailAddress = "email4@xyz.com";
if (Customer.rawValue = "3"|"4"|"7") {
emailAddress = "email1@xyz.com";
}
else if (Customer.rawValue = "5"|"8"|"15"|"20"|"21"|"26") {
emailAddress = "email2@xyz.com";
}
else if (Customer.rawValue = "9"|"10"|"13") {
emailAddress = "email3@xyz.com";
}
else {
emailAddress = "email4@xyz.com";
}
Then I copied this (from the other topic), on the click event of a regular button ,which calls for a second, hidden button:
EmailSubmitButton1.resolveNode("#event").submit.target = "mailto:"+ emailAddress;
EmailSubmitButton1.execEvent("click");
The form worked fine the first time, but after that, all submissions are going to email3@xyz.com. I'm thinkking that the variable emailAddress has now a fixed value, and does not change.
I am new to Javascript, so I might have not written the code properly, any help will be greatyl appreciated!
Thank you.