• 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

how to get confirmation pop-up for delete button

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi..
i am new to stuts.
i am having a jsp page where i have a delete button. below is the code:-

<a href="Delete.do?username=<bean:write name="employee"
property="username" />">Delete</a>
this is map to a action class which is deleting this record.now my question is that i want a pop-up as a confirmation before deleting this record .

where should i write the code?
if i need to put java script then how shuld it be?
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to define a javascript , with confirm option , and depending upon the user choice( i.e Yes or No ) , you get your return value ..
Now passed this return value with request object, where your Action class retrieve it and depending on it you delete the row .

Hope this Help ..
 
Ranch Hand
Posts: 479
1
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Execute the following function when the user clicks on the 'Delete' button.

function confirmation() {
var answer = confirm("Delete this record?")
if (answer){
// Perform action for 'OK'.
}
else{
// Perform action for 'Cancel'.
}
}
 
Ranch Hand
Posts: 137
Hibernate Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add onclick attribute to the anchor tag to invoke the above posted JS function, inside the function when the condition satifies have document.location='yourAction.do?' which would invoke the appropriate action.
 
Alas, poor Yorick, he knew this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic