Body: <p>I have a form that uses an email select form, where the label of each option is a department, and the value is the email or emails associated with that department.</p>
  
  <p>It's working fine, but the notification email just lists the selected email address, and not the department selected. Because some emails are associated with multiple departments, I need to be able to show what department was selected.</p>
  
  <p>There doesn't seem to be a way to customize the notification, so I'd like to add a hidden field, and assign the label of the selected email option as its value. </p>
  
  <p>I tried doing it with javascript, using the code below, but it's not working:</p>
  
  <pre><code>&lt;input type="hidden" id="fields-selectedInterest" class="selectedInterest" name="fields[selectedInterest]"&gt;
  
  &lt;select name="fields[imInterestedIn]" id="fields[imInterestedIn]" required&gt;
      &lt;option value=""&gt;I'm Interested In:&lt;/option&gt;
      &lt;option value="0" &gt;Service 1&lt;/option&gt;
      &lt;option value="1" &gt;Service 2&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;script type="text/javascript"&gt;
      jQuery(document).ready(function($){
          $(document).on('change', 'select[name="fields[imInterestedIn]"]', function(){
              var val1 = $("select[name='fields[imInterestedIn]']").children("option").filter(":selected").text();
  
              $("#fields-selectedInterest").val(val1);
              $("#fields-selectedInterest").change();
          });
      });
  &lt;/script&gt;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-15T20:31:10.983Z
Comments.Text: Hi! have you added the hidden field from Sprout Fields?
Comments.UserDisplayName: Andre L.
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-31T14:25:58.270Z
Comments.Text: @artmem I've tested the code above and it appears to be working (populating the value of `selectedInterest` when `imInterestedIn` changes. Can you elaborate on what you mean when you say it is not working? Is jQuery being loaded? How do you have the hidden field implemented? Are you using Sprout Fields hidden field or a Plain Text field with custom HTML in your form templates? We'll need more info on how to recreate the error to help troubleshoot further.
Comments.UserDisplayName: Ben Parizek
Tags: <emails><plugin-sproutforms><jquery>
Title: Sprout Forms -- Assign email selects LABEL to hidden field (jquery?)
ThreadText: # Sprout Forms -- Assign email selects LABEL to hidden field (jquery?)
  
  (Asked by: username_0 on 2017-06-12)
  
  I have a form that uses an email select form, where the label of each option is a department, and the value is the email or emails associated with that department.
  
  It's working fine, but the notification email just lists the selected email address, and not the department selected. Because some emails are associated with multiple departments, I need to be able to show what department was selected.
  
  There doesn't seem to be a way to customize the notification, so I'd like to add a hidden field, and assign the label of the selected email option as its value.
  
  I tried doing it with javascript, using the code below, but it's not working:
  
  ```
  <input type="hidden" id="fields-selectedInterest" class="selectedInterest" name="fields[selectedInterest]">
  
  <select name="fields[imInterestedIn]" id="fields[imInterestedIn]" required>
      <option value="">I'm Interested In:</option>
      <option value="0" >Service 1</option>
      <option value="1" >Service 2</option>
  </select>
  
  <script type="text/javascript">
      jQuery(document).ready(function($){
          $(document).on('change', 'select[name="fields[imInterestedIn]"]', function(){
              var val1 = $("select[name='fields[imInterestedIn]']").children("option").filter(":selected").text();
  
              $("#fields-selectedInterest").val(val1);
              $("#fields-selectedInterest").change();
          });
      });
  </script>
  
  ```
  
  **Tags:** emails, plugin-sproutforms, jquery
  
  > **Comments:**
  > **username_1**: Hi! have you added the hidden field from Sprout Fields?  
  > **username_2**: @username_0 I've tested the code above and it appears to be working (populating the value of `selectedInterest` when `imInterestedIn` changes. Can you elaborate on what you mean when you say it is not working? Is jQuery being loaded? How do you have the hidden field implemented? Are you using Sprout Fields hidden field or a Plain Text field with custom HTML in your form templates? We'll need more info on how to recreate the error to help troubleshoot further.  
  
  ---
  
  ## 0 answers
  
  