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

Email submit button pulling export value from multiple dropdowns

New Here ,
Aug 16, 2016 Aug 16, 2016

Hoping someone can help here, I have very little experience with javascript and I'm not sure if what I'm trying to achieve is possible but here goes.

I have a pdf form with one dropdown with 5 options that when selected each variable brings up a second dropdown (show/hide js no problem). In each of the 5 dropdowns are a list of names with the export value set as the persons email address. The IDs of each dropdown are Level1, Level2 etc and what I'm trying to achieve is having the export value of the selected dropdown box option pull to a submit button that will email the entire pdf as an attachment. I've gotten as far as finding this.Maildoc and getting it to import the email addresses - but I can only seem to get it to pull values from ALL of the dropdowns rather than just the selected option in the current (shown) dropdown.

A programmer friend tried to help me (a bit blindly because I'm working in DC and he can't access the file) and wrote the following but it's showing an error in oForm not being defined properly so it wont submit the form.

var selected_index = oForm.elements["Level1", "Level2", "Level3", "Level4", "Level5"].selectedIndex;

if(selected_index > 0)

{

   var selected_option_value = oForm.elements["Level1", "Level2", "Level3", "Level4", "Level5"].options[selected_index].value;

}else{

   alert('Please select a Name from the drop down list');

}

this.mailDoc({

bUI: false,

cTo: "selected_option_value"

});

I've been looking at getElementById as another option but I really really have no idea what i'm doing - I know the most basic html and css, javascript is way over my head.

Any help would be greatly appreciated!

TOPICS
Acrobat SDK and JavaScript , Windows
952
Translate
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 ,
Aug 16, 2016 Aug 16, 2016

The code you're using is for a web-page. It's not going to work in a PDF. In addition you have some syntax problems in it.

So what you want to do is assemble the selected values from all five drop-downs and then use them as the recipient addresses when emailing the file?

Translate
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 ,
Aug 16, 2016 Aug 16, 2016

Yeah right, I had a feeling I was off the beaten track with that code.

I need it to pull one email from whichever of the 5 dropdowns is selected. I went the all in approach originally expecting it to create spaces where there was no value not having been selected, but I realise now that was wrong in another direction entirely.

Translate
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 ,
Aug 16, 2016 Aug 16, 2016

What if more than one name is selected in these drop-downs?

Translate
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 ,
Aug 16, 2016 Aug 16, 2016

There is the potential to have this option repeated, but it would be attached to a separate submit button. Each row of dropdown boxes will be attached to a signature input for that specific person to sign and email on.

Translate
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 ,
Aug 16, 2016 Aug 16, 2016

Sorry, I don't follow what you mean... My question is about the scenario where the user selects names in more than one field (Level1 and Level3, for example). What should happen when they then click the Submit button? Which email address should be used?

Translate
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 ,
Aug 16, 2016 Aug 16, 2016

Sorry I should have been clearer. I've been using dropdown inputs because I was under the impression that only one option can be selected. So a user chooses "level 1" and it brings up a 2nd dropdown (which is otherwise hidden until a selection is made) with the names of managers they can choose under that level to get a signature from. So the 5 dropdowns with emails set to export values are labelled Level1-5.

It's currently only required that I set it to send to the one email but I would be interested to see if if there's a way that a second submit button could collect from both selections were there two. I don't know enough about the hierarchy of the office I'm producing this for to be sure about how many people will have to authorise the same form.

Translate
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 ,
Aug 17, 2016 Aug 17, 2016

Each individual field can have a single value selected, yes, but 5 fields

can have up to 5 values selected at the same time.

I'm having difficulty understanding the situation, so if you want further

help you'll need to share your file.

On Tue, Aug 16, 2016 at 11:23 PM, tabathatrouble <forums_noreply@adobe.com>

Translate
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 ,
Aug 19, 2016 Aug 19, 2016

I don't expect a situation where anyone would choose more than one option per dropdown, i'm not thoroughly concerned about limitiing that scenario but if its the only way to achieve what I want then I have no issue.

I've uploaded an example of what the layout of the boxes are here

https://dl.dropboxusercontent.com/u/24413684/example.pdf

there will be up to 100 "names" to choose from in most of the dropdowns to select if that makes a difference.

hopefully that clears it up a bit. thanks.

Translate
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 ,
Aug 19, 2016 Aug 19, 2016

So in this example, do you want to send the file to the address associated with "Person 101", "Person 501", or both?

Translate
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 ,
Aug 19, 2016 Aug 19, 2016

Lets say Person 101 from the first row and Person 501 from the second row - so both but only a single value from each

Translate
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 ,
Aug 19, 2016 Aug 19, 2016
LATEST

OK, but you need to give each field a unique name. It's much more complicated to do it with the duplicate names you've used.

The basic code would be something like this:

var emails = [];

for (var i=1; i<=5; i++) {

    var f = this.getField("Level"+i);

    if (f.display==display.visible) {

        emails.push(f.value);

    }

}

this.mailDoc({

    cTo: emails.join(";")

});

Translate
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