Reputation: 160
I have this button in my view:
<input type="image" name="Command" onclick="CallBtn('SConform')" value="SConform" src='../Images/conform.png' style="float: left;"/>
which calls an action on the controller but i need to add a js confirm window and make it either go ahead with the call if true, or do nothing if false. Does anybody know how could I do it?
Thanks in advance
Upvotes: 0
Views: 474
Reputation: 67505
Try inline confirm dialog like following :
<input type="image" name="Command" onclick="if(confirm('Are you sure ?')) { CallBtn('SConform') }">
Hope this helps.
Upvotes: 1
Reputation: 28611
You can use confirm
, it's not pretty though:
function CallBtn(id) {
if (!confirm("Are you sure?") return;
... rest of existing code...
if you're using jquery or bootstrap then there's nicer options.
Upvotes: 1