Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

navigation(to another JSP page) from JavaScript Confim/Cancel alert not working.

 
Monica Shiralkar
Ranch Hand
Posts: 843
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my JSP page on click on submit I have put one alert Confirm/Cancel. If the user clicks Confirm I want it to navigate to another JSP page.But on clicking Confirm nothing happens.

here is my code for index.jsp


thanks
 
Rob Crowther
author
Ranch Hand
Posts: 297
5
Android Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic