Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confirm using Java Script

 
Karthik Krishnamurthy
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have tried that and it does not work. it submits whether userr clicks ok or cancel.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();" >
 
Karthik Krishnamurthy
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Merrill. That works.

Karthik
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic