javascript - text disappears rapidly after click on 'submit-button' -
got problem. code:
<html> <body> <form> <p>13-7: <input id="in1" type="text"" /><input type="submit" onclick="check(6, 'in1', 'out1')" value="tjek!"/></p> <p id="out1"></p> <p>20-7: <input id="in2" type="text"" /><input type="submit" onclick="check(13, 'in2', 'out2')" value="tjek!" /></p> <p id="out2"></p> <script type="text/javascript"> function check(facit, input, output) { var answer, evaluation; answer = document.getelementbyid(input).value; evaluation = (answer == facit) ? "correct" : "wrong"; document.getelementbyid(output).innerhtml = evaluation; return false; } </script> </form> </body> </html> when click submit-button, 'correct/wrong' shows moment. want stay on site, advice?
the submit buttons submitting form (so reloading page).
change buttons type="button".
Comments
Post a Comment