i'm trying to put together a form that takes the answer to a simple multiplication question and then uses javascript to verify the answer. i want the page to redirect to a new one if the answer is correct, but i also want the form to submit when the viewer hits enter.
when i write the form using input type="submit" the view can hit enter and get a response, but the page won't redirect because the answer is added to the url
when i write the form using input type="button" the page will redirect, but the viewer has to click on the button to get a response.
can i have the best of both worlds? here is my code using "button" below.
My guess would be that if the answer is correct you want to move on to a new question. So why would not put in a button that verifies the question, as in "Check Answer", and then a "Next Question" button for when the user is ready to move to the next. Each would call a separate function, so in the end you get to stay on the page for verification, and next for when the user is ready to move on.
Also if you don't put an input element into a form, there is not form to submit, so no processing. Then the onclick becomes you way to handle flow, and nothing gets added to the end of the url.
Bookmarks