A form will go to another page all by itself, there's no need to create JavaScript code to replicate the browser functionality. Also if you're going to use attributes to attach handlers then you need to explicitly return a true or false value:
Of course, if there are no other values in the form that's an indicator that a form is not really what you need here, a simple link or button would suffice, but we'll not worry about that now. You can now capture the
submit event as before, though the function doesn't need to be as complicated:
Here is a working example (though of course nextPage.jsp does not exist, so when the form submits there will be a 404).