we were wondering if it's possible to have a type of questionnaire in the form of triage with dropdownlists, so depending on the question you select from the first dropdownlist you will see a new dropdown list with new questions, and once you select a new question , a new dropdownlist is displayed with a new set of questions; after 4 iterations the end user will see a final answer; it’s important to mention that the options that you see on the dropdownlist depends on the previous selection; you could see it’s filtered based on the previous selection
Thanks
This is not something that is built into Formulate, but it is something you can implement in combination with Formulate. Here's how I imagine that working.
First, create your fields and assign categories to them, such as in this example:
You can see the "Question 2" category is selected. This renders like this:
You can see the drop down has a data-category="Question 2" data attribute attached to it. You can use that attribute to target the drop down with JavaScript (e.g., document.querySelector('[data-category="Question 2"]')).
Once you have those fields stored to variables, you can attach event handlers and change the options in each drop down. That'd be something like this:
question1.addEventListener('change', function () {
showAndUpdateQuestion2Options();
});
question2.addEventListener('change', function () {
showAndUpdateQuestion3Options();
});
// ...And so on...
finalQuestion.addEventListener('change', function () {
showFinalAnswer();
});
function showAndUpdateQuestion2Options() {
let newOption = document.createElement('option');
newOption.text = 'New Option';
newOption.value = 'new-option';
question2.add(newOption);
question2.classList.add('visible');
}
Consider that pseudo code, as I haven't tested any of it. I'm sure you can revise it according to your needs (e.g., make the dynamic values CMS-editable).
Triage questionnaire
we were wondering if it's possible to have a type of questionnaire in the form of triage with dropdownlists, so depending on the question you select from the first dropdownlist you will see a new dropdown list with new questions, and once you select a new question , a new dropdownlist is displayed with a new set of questions; after 4 iterations the end user will see a final answer; it’s important to mention that the options that you see on the dropdownlist depends on the previous selection; you could see it’s filtered based on the previous selection Thanks
This is not something that is built into Formulate, but it is something you can implement in combination with Formulate. Here's how I imagine that working.
First, create your fields and assign categories to them, such as in this example:
You can see the "Question 2" category is selected. This renders like this:
You can see the drop down has a
data-category="Question 2"
data attribute attached to it. You can use that attribute to target the drop down with JavaScript (e.g.,document.querySelector('[data-category="Question 2"]')
).Once you have those fields stored to variables, you can attach event handlers and change the options in each drop down. That'd be something like this:
Consider that pseudo code, as I haven't tested any of it. I'm sure you can revise it according to your needs (e.g., make the dynamic values CMS-editable).
is working on a reply...