Copy link to clipboard
Copied
Hello,
I am trying to write a script that will submit a form to a specific email address based on which radio button is selected. I found some code for an if/else if setup, but it isn't working. I have three choices in my buttons, but it's only picking up the first email address and ignoring the variable. Also, I am trying to use cSubmitAs in order to submit as a PDF but it just appended cSubmitAs to the end of the email address, so I took it out (so bonus points to the person who helps there). Here's what I have so far:
var nCounty = this.getField("County").value;
if( nCounty = "County1" ) event.value = this.submitForm(
"mailto:jsmith@corpnet.org"
);
else if( nCounty = "County2" ) event.value = this.submitForm(
"mailto:joe.smith@corpcom.org"
);
else if( nCounty = "County3" ) event.value = this.submitForm(
"mailto:jane@corporg.org"
);
I'm trying to teach myself code but am having trouble understanding some of the basics because I can only find information in small chunks.
Any help would be amazing! Thanks ;0)
Meghan
1. For comparisons you must use "==" or "===", not "=". That's used to assign a value.
2. The submitForm method doesn't return a value, so drop the event.value = ... parts from your code.
3. If you want to specify parameters you have to name them (or specify them all, in the order described in the reference).
So change this, for example:
if( nCounty = "County1" ) event.value = this.submitForm(
"mailto:jsmith@corpnet.org"
);
To:
if ( nCounty == "County1" )
this.submitForm({cURL: "mailto:jsm
...Copy link to clipboard
Copied
1. For comparisons you must use "==" or "===", not "=". That's used to assign a value.
2. The submitForm method doesn't return a value, so drop the event.value = ... parts from your code.
3. If you want to specify parameters you have to name them (or specify them all, in the order described in the reference).
So change this, for example:
if( nCounty = "County1" ) event.value = this.submitForm(
"mailto:jsmith@corpnet.org"
);
To:
if ( nCounty == "County1" )
this.submitForm({cURL: "mailto:jsmith@corpnet.org", cSubmitAs: "PDF"});
Copy link to clipboard
Copied
THANK YOU ONE MILLION TRILLION TIMES!!!!!!!
It worked ;0)