onclick submit one of two same form
I included one file (containing a form) two times in php fil开发者_运维知识库e.I want to submit one form with onclick function. both forms are same. i wrote onclick function document.formname.submit();
I want to do somthing like this document.this.form.submit(); please give some solution.
your forms should be something like this
<form name="form1">
......
<input type="submit" value="this submits form1">
</form>
<form name="form2">
......
<input type="submit" value="this submits form2">
</form>
Not like this:
<form name="form1">
......
<input type="submit" value="this submits form1">
<form name="form2">
......
<input type="submit" value="this submits form2">
</form>
</form>
You can not put one form into another.
with a button inside the form, you can do
$('form input[type="button"]').click(function ()
{
$(this.form).submit();
})
edit
ok, so per OP's comment, it's anchors, not inputs:
$('form a').click(function ()
{
$(this).closest('form').submit();
})
精彩评论