wood burning stoves*
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 Android Security Essentials Live Lessons this week in the Android 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: 594
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: navigation(to another JSP page) from JavaScript Confim/Cancel alert not working.
 
Similar Threads
not able to redirect to html file from a jsp
How to make a JSP/HTML page to stay on itself when user clicks on back button on the browser?
can we write javascript functions on struts tags?
how to restrict form submit
Confirm Button