Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

HELP - email address problem - need to reset a variable

Avatar

Former Community Member
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.
2 Replies

Avatar

Level 6
Daeveed:



I think your javascript syntax is problematic. Instead of the syntax



if (Customer.rawValue = "3"|"4"|"7")



try



if (Customer.rawValue == "3"|"4"|"7")



Note the double equals sign. That's the equality comparison operator in javascript. The single equals is assignment.



if that still doesn't work, try



if ((Customer.rawValue == "3") || (Customer.rawValue == "4") || (Customer.rawValue == "7"))



Hope this helps.