• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 297
5
Android Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
And then the flying monkeys attacked. My only defense was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic