- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Send survey result to email address depending on answer to question
- sdoyle
- Topic Author
- Offline
- New Member
Less
More
10 years 5 months ago #100568
by sdoyle
Send survey result to email address depending on answer to question was created by sdoyle
I have a survey that has a dropdown question (Q1) School Name with Answers such as A1: NewSchool - NewTown and A2: OldSchool - OldTown. I need to use the answer to Q1 to send the submitted survey to the relevant School Principal via email. The person submitting the survey won't know the email address. How can I link A1 to principal@schooldomain.edu?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
10 years 5 months ago #100595
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Send survey result to email address depending on answer to question
You can:
1) Add a short-text question right after the drop-down (it must be on the same page)
2) Set up your survey to use JavaScript .
3) Add the script below to the question source of the drop-down. This script will:
- Hide the short-text
- Load the short-text with email addresses depending on the selection in the drop-down
4) Set your notification to use the value in the short-text - manual.limesurvey.org/Creating_a_new_sur..._.26_data_management
1) Add a short-text question right after the drop-down (it must be on the same page)
2) Set up your survey to use JavaScript .
3) Add the script below to the question source of the drop-down. This script will:
- Hide the short-text
- Load the short-text with email addresses depending on the selection in the drop-down
4) Set your notification to use the value in the short-text - manual.limesurvey.org/Creating_a_new_sur..._.26_data_management
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var thisQuestion = $('#question{QID}'); var emailQuestion = $(thisQuestion).nextAll('.text-short:eq(0)'); // Hide the email address question $(emailQuestion).hide(); // Listener on the dropdown $('select', thisQuestion).change(function(event) { // Define the email address var emailAddress = ''; switch($(this).val()) { case 'A1' : emailAddress = 'principal@schooldomain1.edu'; break; case 'A2' : emailAddress = 'principal@schooldomain2.edu'; break; case 'A3' : emailAddress = 'principal@schooldomain3.edu'; break; } // Load the hidden email question $('input.text', emailQuestion).val(emailAddress); }); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: sdoyle
The topic has been locked.
- sdoyle
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
10 years 5 months ago #100785
by sdoyle
Replied by sdoyle on topic Send survey result to email address depending on answer to question
Excellent, worked a treat
The topic has been locked.