Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

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

Send survey result to email address depending on answer to question 1 Jahr 1 Monat her #100568

  • sdoyle
  • sdoyles Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 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 Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Send survey result to email address depending on answer to question 1 Jahr 1 Monat her #100595

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4369
  • Dank erhalten: 829
  • Karma: 381
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: sdoyle

Send survey result to email address depending on answer to question 1 Jahr 1 Monat her #100785

  • sdoyle
  • sdoyles Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 3
  • Karma: 0
Excellent, worked a treat :cheer:
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.189 Sekunden
Donation Image