File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes navigation(to another JSP page) from JavaScript Confim/Cancel alert not working. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "navigation(to another JSP page) from JavaScript Confim/Cancel alert not working." Watch "navigation(to another JSP page) from JavaScript Confim/Cancel alert not working." New topic
Author

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

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 639
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

Joined: Nov 06, 2012
Posts: 295
    
    5

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).


Read my books: Hello! HTML5 & CSS3 | HTML5 in Action | Read my blog
 
Consider Paul's rocket mass heater.
 
subject: navigation(to another JSP page) from JavaScript Confim/Cancel alert not working.