Once I put questions in a form as well as a submit button, how to I alert users that they are correct or incorrect? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Once I put questions in a form as well as a submit button, how to I alert users that they are correct or incorrect?

I am creating a quiz but I am not sure how to tell the person they are correct or incorrect. How do I do this? https://code.sololearn.com/WLt0eiCehzpp/?ref=app

12th May 2019, 12:18 PM
Kaenen
Kaenen - avatar
7 Answers
+ 1
Kaenen a working sample of your program In html part, whenever you click on radio the value is sent to setval() function. When submit button is pressed, JavaScript part checks if the selected radio button is equal to answer and shows corresponding alert message https://code.sololearn.com/W9iOtjymz2FK/?ref=app
12th May 2019, 1:37 PM
‎ ‏‏‎Anonymous Guy
+ 4
Add: HTML: <form> some code... <input type="submit" onclick="func()" /> </form> JS: function func() { // if statement alert("some text..."); //else if statement alert("some text..."); //else alert("some text..."); }
12th May 2019, 12:33 PM
CodeFu
CodeFu - avatar
+ 3
Please link your code
12th May 2019, 12:20 PM
‎ ‏‏‎Anonymous Guy
+ 3
‎ ‏‏‎Sreejith thank you! i get it now!
12th May 2019, 2:33 PM
Kaenen
Kaenen - avatar
+ 2
If u are using Javascript u need something like this if (answer == question[1]) { alert('Correct!'); But better you show us your code.
12th May 2019, 12:30 PM
Guezi Louay
Guezi Louay - avatar
12th May 2019, 12:33 PM
Kaenen
Kaenen - avatar
+ 2
🇲🇰Maksi - Vik🇲🇰 for the if statements, what do i put to make it the correct answer, which is 42?
12th May 2019, 12:56 PM
Kaenen
Kaenen - avatar