Reputation: 1063
i have a form that i stop from submitting and when confirm message pops up and user clicks yes i want when that happens to submit the form,how can i do that?i tried using fireEvent like this but it wont work...in firebug it says e is undefined.
window.addEvent('domready', function(){
var form=document.adminForm;
form.addEvent('submit', function(e){
var result=confirm("Are you sure!?");
e.stop();
if(result){
form.fireEvent("submit");
}
});
});
Upvotes: 1
Views: 407
Reputation: 26165
you need to stop the event before the confirm and submit after. http://jsfiddle.net/dimitar/qAx6H/
var form=document.id('adminForm');
form.addEvent('submit', function(e){
e && e.stop();
if (confirm('Are you sure?')){
this.submit();
}
});
Upvotes: 1
Reputation: 2665
As far as I understand from your question you want simple confirmation befor submittiong the form. If so, you can use this tiny script:
<input type="submit" OnClick="return confirm('Are you sure!?');" ... />
It will pop-up modal with Ok/Cancel buttons, but works fine for me.
Upvotes: 0