Let’s work together.
Interested in working together? Fill out some info and we will be in touch shortly! We can't wait to hear from you!
<div id="frenchQuizForm">
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Locate the form inside our container (the Form Block will output a <form> tag)
var quizForm = document.querySelector("#frenchQuizForm form");
if (quizForm) {
quizForm.addEventListener("submit", function(event) {
event.preventDefault(); // Prevent the default Squarespace form submission
var score = 0;
// Calculate score from quiz questions (ensure the Field Names match those set in the Form Block)
var q1 = quizForm.querySelector("input[name='question1']:checked");
if (q1) { score += parseInt(q1.value, 10); }
var q2 = quizForm.querySelector("input[name='question2']:checked");
if (q2) { score += parseInt(q2.value, 10); }
// If you add more questions, repeat the above block for each (e.g., question3, question4, etc.)
// Retrieve the Budget and Time inputs
var budgetInput = quizForm.querySelector("input[name='budget']:checked");
var budget = budgetInput ? budgetInput.value : "";
var timeInput = quizForm.querySelector("input[name='time']");
var time = timeInput ? parseInt(timeInput.value, 10) : 0;
// Debug output (optional)
console.log("Score:", score, "Budget:", budget, "Time:", time);
// Determine the redirection URL based on score and budget
var redirectUrl = "";
if (score >= 0 && score <= 10) {
if (budget === "low") {
redirectUrl = "/courses/a1-low-budget";
} else if (budget === "high") {
redirectUrl = "/courses/a1-high-budget";
}
} else if (score > 10 && score <= 20) {
if (budget === "low") {
redirectUrl = "/courses/a2-low-budget";
} else if (budget === "high") {
redirectUrl = "/courses/a2-high-budget";
}
} else {
// Default redirection if conditions do not match
redirectUrl = "/contact";
}
// Redirect the user
window.location.href = redirectUrl;
});
}
});
</script>