• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Submitting form based on 2 dropdown selections - Javascript

New Here ,
Dec 01, 2017 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

592

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
community guidelines
Community Expert ,
Dec 01, 2017 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.

Votes

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
community guidelines
Community Expert ,
Dec 01, 2017 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.

Votes

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
community guidelines
New Here ,
Dec 01, 2017 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

Votes

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
community guidelines
LEGEND ,
Dec 01, 2017 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.

Votes

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
community guidelines
New Here ,
Dec 01, 2017 Dec 01, 2017

Copy link to clipboard

Copied

I removed the quotes and still no luck

Votes

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
community guidelines
LEGEND ,
Dec 01, 2017 Dec 01, 2017

Copy link to clipboard

Copied

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

Votes

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
community guidelines
New Here ,
Dec 01, 2017 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

Votes

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
community guidelines
LEGEND ,
Dec 01, 2017 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.

Votes

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
community guidelines
New Here ,
Dec 01, 2017 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.

Votes

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
community guidelines
Community Expert ,
Dec 01, 2017 Dec 01, 2017

Copy link to clipboard

Copied

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

Votes

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
community guidelines
New Here ,
Dec 01, 2017 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

Votes

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
community guidelines
Community Expert ,
Dec 01, 2017 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.

Votes

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
community guidelines
LEGEND ,
Dec 01, 2017 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 >

Votes

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
community guidelines
LEGEND ,
Dec 01, 2017 Dec 01, 2017

Copy link to clipboard

Copied

It’s extremely important to find how to copy and paste. Retrying will not cut it.

Votes

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
community guidelines
LEGEND ,
Dec 01, 2017 Dec 01, 2017

Copy link to clipboard

Copied

Sorry retyping, dang autocorrect.

Votes

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
community guidelines
New Here ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

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.submitForm({

cURL: "mailto:" + email,

cSubmitAs:"PDF"

});

}

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

I'm having problems with simply copying and paste and must click the HTML icon to be able to paste, then format goes all weird.

Votes

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
community guidelines
Community Expert ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

LATEST

Are there any errors reported in the Console?

Here's a tutorial on the topic.

https://www.pdfscripting.com/public/images/Free_Videos/BeginJS_Console_Alt_mp4.cfm

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
LEGEND ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

Is it really all like that, a single line? Or are you copy/pasting it in pieces for some reason? Or did the forum mess it up? Either way it's very hard to read. If you're having trouble with copy/paste please say what you do and what happens, this is an important thing to work.

Votes

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
community guidelines
LEGEND ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

Looking over it, though, here are some thoughts.

1. Try adding an app.alert line immediately before the if (email... line, to confirm the value of email.

2. If it isn't as expected also use app.alert to report on the values of Dropdown1 and Dropdown2.

3. You have an extra dot in c.URL I believe.

Votes

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
community guidelines
New Here ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

Still no luck. Its just ignoring all commands based on the results from the dropdowns

Votes

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
community guidelines
LEGEND ,
Dec 04, 2017 Dec 04, 2017

Copy link to clipboard

Copied

You're using app.alert to check the values of email, Dropdown1 and Dropdown2 ?

Votes

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
community guidelines