开发者

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();
})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜