Reputation: 18306
I have these code below :
<form name="submissions" action="/" onsubmit="window.open('', 'foo', 'width=900,height=900,status=yes,resizable=yes,scrollbars=yes')" target="foo" method="post">
.......
<input type="submit" id="printbtn" name="printbtn" value="Print" />
<input type="submit" id="editbtn" name="editbtn" value="Edit" />
</form>
* Edited *
the window.open should only happens when the Print button is clicked. I want to remove onsubmit() event and do it with jQuery. How can I do it?
Upvotes: 4
Views: 26754
Reputation: 8189
Will this work?
$('form[name="submissions"]').submit(function(event){
event.preventDefault();
// Do other stuff
});
UPDATE: Actually, try this out...
$(function(){
$('form[name="submissions"]').removeAttr('onsubmit')
.submit(function(event){
event.preventDefault();
// This cancels the event...
});
// This should fire your window opener...
$('#printbtn').click(function(){
window.open('', 'foo', 'width=900,height=900,status=yes,resizable=yes,scrollbars=yes');
})
});
Should remove the onsubmit, and prevent the form from submitting...
Upvotes: 7
Reputation: 2177
If you just want to remove the onsubmit function then I think this should do the trick.
$("form[name='submissions']").attr('onsubmit', '');
Upvotes: 1
Reputation: 364
$("#btn").on('click', function(e) {
window.open('', 'foo', 'width=900,height=900,status=yes,resizable=yes,scrollbars=yes');
e.preventDefault();
});
Upvotes: 2
Reputation: 2248
$('form[name=submission]').submit(function(e) {
e.preventDefault();
//your code
});
Hope this helps.
Upvotes: 4