I need to get an .click() event and prevent form from behaving as it was initially designed and make my own changes and submit. How is it possible?
EDIT: Form input actually has an onclick defined behavior. I need to redefine it somehow.
EDIT: Some code
<form action='link' method='get'>
<input type="image" name="name" id="id" class="class" onclick="this.form.action='some_link'" title="Title" value="" src="image.gif">
</form>
I need to get an .click() event and prevent form from behaving as it was initially designed and make my own changes and submit. How is it possible?
EDIT: Form input actually has an onclick defined behavior. I need to redefine it somehow.
EDIT: Some code
<form action='link' method='get'>
<input type="image" name="name" id="id" class="class" onclick="this.form.action='some_link'" title="Title" value="" src="image.gif">
</form>
Share
Improve this question
edited Nov 17, 2010 at 17:17
Denys S.
asked Nov 17, 2010 at 17:04
Denys S.Denys S.
6,53313 gold badges45 silver badges65 bronze badges
1
- Possible duplicate of stackoverflow./questions/1263852/… or stackoverflow./questions/699065/… or many many others. – Shikiryu Commented Nov 17, 2010 at 17:10
3 Answers
Reset to default 5If you don't want it to submit the form, return false
at the end of your click function. If you want to submit the form, use the form element and call the submit function on it:
$('#myFormID').submit();
$('#form').submit(function(e) {
// Some code
});
I think it's enough.
You could use something like this (haven't tested it but it should work)
form = $("#yourform");
button = $("#yoursubmit");
button.click(function(){
dosomething();
form.submit();
return false;});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745415306a4626720.html
评论列表(0条)