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

CC BY-SA 3.0
2017-08-15T20:31:10.983Z
Hi! have you added the hidden field from Sprout Fields?
Andre L.
CC BY-SA 3.0
2017-08-31T14:25:58.270Z
@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.
Ben Parizek
<emails><plugin-sproutforms><jquery>
Sprout Forms -- Assign email selects LABEL to hidden field (jquery?)
# 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:



    I'm Interested In:
    Service 1
    Service 2

**Tags:** emails, plugin-sproutforms, jquery
> **Comments:**
> **username_1**: Hi! have you added the hidden field from Sprout Fields?  
> **username_2**: @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.  

---

## 0 answers

