0
HTML issues
Guys help me with this. In my code, after submission and being marked, in code playground, it works well and returns mark and the red and green highlights. But when ran in a browser window, it doesn't do that on submission, but when the back arrow is clicked on the window screen will the score and highlights occur. Why is this so pls? PS. Pls test the code both on code playground and on a browser window. https://code.sololearn.com/WDZegXr3KE9x/?ref=app
3 Answers
+ 2
You should remove the onclick event from the submit button and add onsubmit event on your form
<form onsubmit="return mark()">
And return false on the last row
function mark() {
...
return false;
}
+ 1
When you press the submit button it submits the form which redirects you to the action destination which is the same page since you donât have action attribute. So the click event will not be executed. We prevent the form submission by returning false .
0
Toni Isotalo WOW. IT WORKED. Pls can you explain the difference between adding the function in the onclick event of the submit button and in the onsubmit event of the form?
Also what does the return false do?