Hello, everyone!
I’m having trouble with creating an interaction on my website. I have a quick quiz on the home page where I ask how much time people have been working at the same company. To answer this question, the visitors can use a slider to select their response. What I would like to do is to show a specific message to each possibility of an answer to that question. (Like, if the person says: 1 year, then when the quiz is submitted show a message of "That’s cool! " )
Anyone can help me out on how to do that?
@danielle-leite-ribei The Javascript switch statement would be a way to handle this task. Something like this:
$w.onReady(function () {
$w("#slider1").onChange((event) =>{
switch (event.target.value) {
case 1:
$w("#text1").text = "That's cool!";
break;
case 2:
$w("#text1").text = "That's really cool!";
break;
case 3:
$w("#text1").text = "That's incredibly cool!";
break;
default:
$w("#text1").text = "That's more than cool!";
break;
}
})
});
Thank you so much, @tony-brunsman !! This solved my problem!
(Just as a piece of additional information, if I wanted to show the message after they submit the answer, how could I add an onClick function? )
@danielle-leite-ribei if this was going to be in a submit button, then the first line would be
$w("#buttonName").onClick((event)=>{