Submitting form based on 2 dropdown selections - Javascript

New Here ,
Dec 01, 2017

Copy link to clipboard

Copied

Literally a noob when it comes to javascripting. I'm wanting to send a pdf form based on 2 dropdown selections when selecting a submit button. I could be miles out or so close but literally have no idea of what I'm doing at this level. What I achieved so far is from scanning the web. ***Please note I am using a Adobe Acrobat Pro DC

Dropdown 1 = Head Office and Sub Team

Dropdown 2 = Constructive and Electrical

Code iv tried so far but its ignoring my command:

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

var Dropdown2 = this.getField("Dropdown2")value;

var email = "";

if ("Dropdown1" == "Head Office" && "Dropdown2" == "Constructive")

{

var email = "jasonsdking@me.com, constructive@hotmail.com";

}

else if ("Dropdown1" == "Head Office && "Dropdown2" == "Electrical")

{

var email = "jasonsdking@me.com, electrical@hotmail.com";

}

else if ("Dropdown1" == "Sub Team" && "Dropdown2" == "Constructive")

{

var email = "jasonsdking1@me.com, constructive@hotmail.com";

}

else if ("Dropdown1 == "Sub Team" && "Dropdown2" == "Electrical")

{

var email = "jasonsdking1@me.com, electrical@hotmail.com":

}

else

{

email = "kingysnewstart@Hotmail.co.uk"

}

if (email !="")

{

this.submissionForm({

c.URL: "mailto:" + email,

cSubmitAs: "PDF"

});

}

Currently it attaches to an email addressed to kingysnewstart@Hotmail.co.uk and blanks my commands of picking from the two drop downs. Please note all emails are fake except the personal ones jasonsdking@me.com and Kingysnewstart@Hotmail.com for privacy reasons., and that there will be 20+ emails addresses for each selection.

It would be ideal if  the title read - SRI: Dropdown1 Option + Dropdown 2 Option, and also that specific fields are filled in before sending (Text box 1 and text box 2)

Please assist if possible, probably asking a bit to much to be honest.

Regards

Jason King

TOPICS
Acrobat SDK and JavaScript

Views

290

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Submitting form based on 2 dropdown selections - Javascript

New Here ,
Dec 01, 2017

Copy link to clipboard

Copied

Literally a noob when it comes to javascripting. I'm wanting to send a pdf form based on 2 dropdown selections when selecting a submit button. I could be miles out or so close but literally have no idea of what I'm doing at this level. What I achieved so far is from scanning the web. ***Please note I am using a Adobe Acrobat Pro DC

Dropdown 1 = Head Office and Sub Team

Dropdown 2 = Constructive and Electrical

Code iv tried so far but its ignoring my command:

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

var Dropdown2 = this.getField("Dropdown2")value;

var email = "";

if ("Dropdown1" == "Head Office" && "Dropdown2" == "Constructive")

{

var email = "jasonsdking@me.com, constructive@hotmail.com";

}

else if ("Dropdown1" == "Head Office && "Dropdown2" == "Electrical")

{

var email = "jasonsdking@me.com, electrical@hotmail.com";

}

else if ("Dropdown1" == "Sub Team" && "Dropdown2" == "Constructive")

{

var email = "jasonsdking1@me.com, constructive@hotmail.com";

}

else if ("Dropdown1 == "Sub Team" && "Dropdown2" == "Electrical")

{

var email = "jasonsdking1@me.com, electrical@hotmail.com":

}

else

{

email = "kingysnewstart@Hotmail.co.uk"

}

if (email !="")

{

this.submissionForm({

c.URL: "mailto:" + email,

cSubmitAs: "PDF"

});

}

Currently it attaches to an email addressed to kingysnewstart@Hotmail.co.uk and blanks my commands of picking from the two drop downs. Please note all emails are fake except the personal ones jasonsdking@me.com and Kingysnewstart@Hotmail.com for privacy reasons., and that there will be 20+ emails addresses for each selection.

It would be ideal if  the title read - SRI: Dropdown1 Option + Dropdown 2 Option, and also that specific fields are filled in before sending (Text box 1 and text box 2)

Please assist if possible, probably asking a bit to much to be honest.

Regards

Jason King

TOPICS
Acrobat SDK and JavaScript

Views

291

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 01, 2017 0
Most Valuable Participant ,
Dec 01, 2017

Copy link to clipboard

Copied

If that's your real code it shouldn't work at all, as you used an incorrect function name ("submissionForm").

Replace that part with:

this.submitForm({

     cURL: "mailto:" + email,

     cSubmitAs: "PDF"

});

Also, drop the "var" keyword before the email variable in all places except for the first instance.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
Most Valuable Participant ,
Dec 01, 2017

Copy link to clipboard

Copied

It would be ideal if  the title read - SRI: Dropdown1 Option + Dropdown 2 Option, and also that specific fields are filled in before sending (Text box 1 and text box 2)

- Read up on the mailto syntax. You can specify the subject line just like the target email addresses

- Set the fields as required to force their validation before the file is submitted.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
New Here ,
Dec 01, 2017

Copy link to clipboard

Copied

submissionForm was a typo as I could not copy and past. It was this.submitForm and I deleted the vars to no success still bypasses them

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
Most Valuable Participant ,
Dec 01, 2017

Copy link to clipboard

Copied

Also, you write

if ("Dropdown1" == "Head Office" && "Dropdown2" == "Constructive")

This is just saying: does the string "Dropdown1" equal the string

"Head Office" (etc.) Of course, it never does. You want the VALUE OF

THE VARIABLE Dropdown1, not the string "Dropdown1". When you want the

value of the variable, don't put that in quotes.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
New Here ,
Dec 01, 2017

Copy link to clipboard

Copied

I removed the quotes and still no luck

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
Most Valuable Participant ,
Dec 01, 2017

Copy link to clipboard

Copied

What does it now say in the console when this code is run?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
New Here ,
Dec 01, 2017

Copy link to clipboard

Copied

Sadly your dealing with an idiot when it comes to this stuff so sorry if its like speaking to a child and is frustrating. Not sure what you mean by what does it say in console when the code is run but when I Ok in the Create and Edit Javascripts window it shows no errors. I then go into preview mode and press the submit button. With even Dropdown1 as Sub Team and Dropdown2 as Electrical selected it ignores the written commands of who to email specifically and processes this part of the command:

else

{

email = kingysnewstart@Hotmail.co.uk

}

If you could write out how the code should exactly read it would defo be more helpful. Again I can understand if you wish not to.

Thanks

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
Most Valuable Participant ,
Dec 01, 2017

Copy link to clipboard

Copied

You just need to look in the JavaScript window after you click the button. Any messages?

Also please paste the code exactly as it is today. The combination of code and messages may help us help you fix your code. Please don’t ask us to write it for you.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
New Here ,
Dec 01, 2017

Copy link to clipboard

Copied

No message at all.

Code is exactly:

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

var Dropdown2 = this.getField("Dropdown2").value;

var email = "";

if(Dropdown1 == "Head Office" && Dropdown2 == "Constructive")

{

email="Specific Email Addresses";

}

else if(Dropdown1 == "Head Office" && Dropdown2 == "Electrical")

{

email="Specific Email Addresses";

}

else if(Dropdown1 == "Sub Team" && Dropdown2 == "Constructive")

{

email="Specific Email Addresses";

}

else if(Dropdown1 == "Sub Team" && Dropdown2 == "Electrical")

{

email="Specific Email Addresses";

}

else

{

email="Specific Email Addresses"

}

if(email !="")

{

this.submissionForm({

c.URL: "mailto:" + email,

cSubmitAs:"PDF"

});

}

Specific email address will be added at my end when problem resolved.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
Most Valuable Participant ,
Dec 01, 2017

Copy link to clipboard

Copied

You didn't fix the errors I pointed out with submitForm and the cURL parameter.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
New Here ,
Dec 01, 2017

Copy link to clipboard

Copied

that again is a typo. its exactly how you stated but I cannot simply copy and paste the who thing and id imagine its just autocorrected as I was typing. sorry

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
Most Valuable Participant ,
Dec 01, 2017

Copy link to clipboard

Copied

We can't help you without knowing the exact code you're using, or seeing the actual file.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0
Most Valuable Participant ,
Dec 01, 2017

Copy link to clipboard

Copied

Your code seems to have been edited and ruined by a moderator, I can no longer make head or tail out of it. Try pasting again but change any personal info or email. Also don’t leave in anything like a html < tag >

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2017 0