aspose file tools*
The moose likes Struts and the fly likes Confirm using Java Script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Confirm using Java Script" Watch "Confirm using Java Script" New topic
Author

Confirm using Java Script

Karthik Krishnamurthy
Ranch Hand

Joined: Feb 04, 2005
Posts: 118
Hi,
I have an application where in the user clicks on a delete Data button.

I want to use java script to confirm deletion and call the action handler only if he clicks ok.

Is there some way to this.

If so could you please give some kind of code structure.

Thanks in advance
Karthik
mona mittal
Greenhorn

Joined: Jan 26, 2006
Posts: 7
You can call a javascript function on "onClick" event and in this javascript function have something like an confirm() dialog which have Ok and Cancel buttons. Later you can handle your processing depending upon what user clicks, i.e. Ok or cancel.

Hope that helps!
Karthik Krishnamurthy
Ranch Hand

Joined: Feb 04, 2005
Posts: 118
Hi,

I have tried that and it does not work. it submits whether userr clicks ok or cancel.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I've used this technique often, and it works fine for me. Here's some sample code.

<input type="button" value="delete" onklick="if (confirm('Are you sure?')) this.form.submit();" >


Merrill
Consultant, Sima Solutions
Karthik Krishnamurthy
Ranch Hand

Joined: Feb 04, 2005
Posts: 118
Thanks a lot Merrill. That works.

Karthik
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confirm using Java Script