[英]onclick submit one of two same form
I included one file (containing a form) two times in php file.I want to submit one form with onclick function. 我在php文件中两次包含一个文件(包含一个表单)。我想使用onclick函数提交一个表单。 both forms are same. 两种形式是相同的。 i wrote onclick function document.formname.submit(); 我写了onclick函数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: 好的,所以根据OP的评论,它是锚点,而不是输入:
$('form a').click(function ()
{
$(this).closest('form').submit();
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.