Skip to main content
Participating Frequently
August 16, 2016
Question

Email submit button pulling export value from multiple dropdowns

  • August 16, 2016
  • 1 reply
  • 1083 views

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!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 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?

Participating Frequently
August 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.

try67
Community Expert
Community Expert
August 16, 2016

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