submitting a form based upon country, state, then zip code
To start, I'm a noob when it comes to JavaScript. So, sorry right off that bat!
What I'm trying to do is email certain individuals based upon country, then state, then zip code within a range. For example, for folks in Texas, only a few handle accounts within a 5 digit zip code range with a prefix of 750**. I've set the field variable in the code for zip_code but, I'm not sure how to have it look for zip codes under a "wildcard" search. The following is the code and I've indicated the lines below in red and bold that I need help with. Please help!
var state = this.getField("state").value;
console.println("state: = " + state);
var country = this.getField("country").value;
console.println("country: = " + country);
var zip_code = this.getField("zip_code").value;
console.println("zip_code: = " + zip_code);
var email = "";
if (country == " - Select a Country -" && state == " - Select a State -")
{
app.alert("You need to select a Country first");
}
else if (country == "USA" && state == "Alaska" || country == "USA" && state == "Colorado" || country == "USA" && state == "Idaho" || country == "USA" && state == "Montana" || country == "USA" && state == "Oregon" || country == "USA" && state == "Utah" || country == "USA" && state == "Washington" || country == "USA" && state == "Wyoming")
{
email = "beverly.kelly@jstus.com,gam@jstus.com";
}
else if (country == "USA" && state == "Alabama")
{
email = "joe.gillis@jstus.com,Julie.Green@jstus.com,craig.skok@jstus.com,gam@jstus.com";
}
else if (country == "Brazil" || country == "Chile" || country == "Costa Rica" || country == "Honduras" || country == "Venezuela")
{
email = "fabio.nakano@jstus.com,odeney.souza@jstus.com,gam@jstus.com";
}
else if (country == "Colombia")
{
email = "fabio.nakano@jstus.com,odeney.souza@jstus.com,felipe.escoto@jstus.com,gam@jstus.com";
}
else if (country == "Canada")
{
email = "beverly.kelly@jstus.com,rick.nunemacher@jstus.com,gam@jstus.com";
}
else if (country == "Mexico")
{
email = "armando.corona@jstus.com,felipe.escoto@jstus.com,omar.teran@jstus.com,jim.kellum@jstus.com,gam@jstus.com";
}
else if (country == "USA" && state == "Arizona")
{
email = "armando.corona@jstus.com,don.oldfield@jstus.com,doug@dersalesinc.com,jim.kellum@jstus.com,felipe.escoto@jstus.com,gam@jstus.com";
}
else if (country == "USA" && state == "Texas" && zip_code == "750..")
{
email = "armando.corona@jstus.com,don.oldfield@jstus.com,jim.kellum@jstus.com,gam@jstus.com";
}
else
{
email = "gam@jstus.com";
}
if (email != "")
{
this.submitForm({
cURL: "mailto:" + email,
cSubmitAs: "PDF"
});
}
