Welcome, Guest
Username: Password: Remember me

TOPIC: Send survey result to email address depending on answer to question

Send survey result to email address depending on answer to question 9 months 2 weeks ago #100568

  • sdoyle
  • sdoyle's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
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 This email address is being protected from spambots. You need JavaScript enabled to view it. ?
The administrator has disabled public write access.

Send survey result to email address depending on answer to question 9 months 2 weeks ago #100595

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4050
  • Thank you received: 740
  • Karma: 341
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

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

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: sdoyle

Send survey result to email address depending on answer to question 9 months 1 week ago #100785

  • sdoyle
  • sdoyle's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Excellent, worked a treat :cheer:
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.126 seconds
Donation Image