是否可以一次提交两个表格 [英] Is it possible to submit two forms at a time

查看:56
本文介绍了是否可以一次提交两个表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我在提交表格时需要一点点澄清,请

建议。


在一个页面中我有两个表格,还有两个提交按钮。

(即)


< form name =" myform"行动= QUOT; test.php的"方法= QUOT;交" >

< input type =" text"名称= QUOT; myform_name" >

< input type =" text"名称= QUOT; myform_id" >

< input type =" text"名称= QUOT; myform_no" >

< input type =" submit"值= [提交" />

< / form>


< form name =" myform1"行动= QUOT; test.php的" >

< input type =" text"名称= QUOT; myform1_name" >

< input type =" text"名称= QUOT; myform1_id" >

< input type =" text"名称= QUOT; myform1_no" >

< input type =" submit"值= [提交" />

< / form>


现在我可以提交两张表格中的所有元素

单击任何一个提交按钮。


谢谢&问候

摩西

Hi All,

I need a small clarification in submitting the forms, Ur
suggestions please.

In a page I have two form and also two submit butons.
(ie)

<form name="myform" action="test.php" method="post" >
<input type="text" name="myform_name" >
<input type="text" name="myform_id" >
<input type="text" name="myform_no" >
<input type="submit" value="Submit" />
</form>

<form name="myform1" action="test.php" >
<input type="text" name="myform1_name" >
<input type="text" name="myform1_id" >
<input type="text" name="myform1_no" >
<input type="submit" value="Submit" />
</form>

Now is it possible to submit all the elements from the two form when I
click any one of the submit button.

Thanks & Regards
Moses

推荐答案

你好!


你可以使用javascript提交许多表单。

使用onsubmit操作创建表单序列化数组并发送它。

On 21 ??×,08:26,mosesdinaka ... @ gmail.com"

< mosesdinaka ... @ gmail.comwrote:
Hello!

You can submit many forms at ones with javascript.
Use onsubmit action for create forms serialize array and send it.
On 21 ??×, 08:26, "mosesdinaka...@gmail.com"
<mosesdinaka...@gmail.comwrote:

现在可以全部提交当我单击任何一个提交按钮时,来自两个表单的元素。
Now is it possible to submit all the elements from the two form when I
click any one of the submit button.


mo **** ********@gmail.com 写道:
mo************@gmail.com wrote:

大家好,


我在提交表格时需要一点点澄清,请给我们一些建议。


在一个页面中,我有两个表格,还有两个提交按钮。


(即)


< form name =" myform"行动= QUOT; test.php的"方法= QUOT;交" >

< input type =" text"名称= QUOT; myform_name" >

< input type =" text"名称= QUOT; myform_id" >

< input type =" text"名称= QUOT; myform_no" >

< input type =" submit"值= [提交" />

< / form>


< form name =" myform1"行动= QUOT; test.php的" >

< input type =" text"名称= QUOT; myform1_name" >

< input type =" text"名称= QUOT; myform1_id" >

< input type =" text"名称= QUOT; myform1_no" >

< input type =" submit"值= [提交" />

< / form>


现在我可以提交两张表格中的所有元素

单击任何一个提交按钮。


谢谢&问候

摩西
Hi All,

I need a small clarification in submitting the forms, Ur
suggestions please.

In a page I have two form and also two submit butons.
(ie)

<form name="myform" action="test.php" method="post" >
<input type="text" name="myform_name" >
<input type="text" name="myform_id" >
<input type="text" name="myform_no" >
<input type="submit" value="Submit" />
</form>

<form name="myform1" action="test.php" >
<input type="text" name="myform1_name" >
<input type="text" name="myform1_id" >
<input type="text" name="myform1_no" >
<input type="submit" value="Submit" />
</form>

Now is it possible to submit all the elements from the two form when I
click any one of the submit button.

Thanks & Regards
Moses






是的,但没有PHP。

PHP没有知道浏览器中发生了什么。它只发送

html / javascript / images /无论浏览器显示什么。


所以试试Javascript,该语言存在于浏览器中。

但请注意,有些人选择在他们的

浏览器中禁用Javascript。


如果你去Javascript,只需添加一堆隐藏字段在两种形式中,并且

在使用其他表单的值提交之前填写它们。

如果您需要更多帮助:comp.lang.javascript,一个活跃组。


问候,

Erwin Moller

Hi,

Yes, but not with PHP.
PHP has NO KNOWLEDGE what is going on in the browser. It only sends the
html/javascript/images/whatever the browser displays.

So try Javascript, that language lives in a browser.
Note however that some people choose to have Javascript disabled in their
browser.

If you go Javascript, just add a bunch of hidden fields in both forms, and
fill them before submitting with the values from the other form.
If you need more help: comp.lang.javascript, an active group.

Regards,
Erwin Moller


mo ************ @ gmail.com 写道:

大家好,


我在提交表格时需要一点点澄清,请给我们一些建议。


在一个页面中,我有两个表格,还有两个提交按钮。


(即)


< form name =" myform" ;行动= QUOT; test.php的"方法= QUOT;交" >

< input type =" text"名称= QUOT; myform_name" >

< input type =" text"名称= QUOT; myform_id" >

< input type =" text"名称= QUOT; myform_no" >

< input type =" submit"值= [提交" />

< / form>


< form name =" myform1"行动= QUOT; test.php的" >

< input type =" text"名称= QUOT; myform1_name" >

< input type =" text"名称= QUOT; myform1_id" >

< input type =" text"名称= QUOT; myform1_no" >

< input type =" submit"值= [提交" />

< / form>


现在我可以提交两张表格中的所有元素

单击任何一个提交按钮。


谢谢&问候

摩西
Hi All,

I need a small clarification in submitting the forms, Ur
suggestions please.

In a page I have two form and also two submit butons.
(ie)

<form name="myform" action="test.php" method="post" >
<input type="text" name="myform_name" >
<input type="text" name="myform_id" >
<input type="text" name="myform_no" >
<input type="submit" value="Submit" />
</form>

<form name="myform1" action="test.php" >
<input type="text" name="myform1_name" >
<input type="text" name="myform1_id" >
<input type="text" name="myform1_no" >
<input type="submit" value="Submit" />
</form>

Now is it possible to submit all the elements from the two form when I
click any one of the submit button.

Thanks & Regards
Moses



摩西,


正如其他人所说,你可以用javascript,但很多用户已经禁用了b $ b javascript。


但是,你在两种表格上都有相同的目标 - 你不需要两个

表格。你可以这样做:


< form name =" myform"行动= QUOT; test.php的"方法= QUOT;交" >

< input type =" text"名称= QUOT; myform_name" >

< input type =" text"名称= QUOT; myform_id" >

< input type =" text"名称= QUOT; myform_no" >

< input type =" submit"命名= [提交" value =" First Button" />


< input type =" text"名称= QUOT; myform1_name" >

< input type =" text"名称= QUOT; myform1_id" >

< input type =" text"名称= QUOT; myform1_no" >

< input type =" submit"命名= [提交" value =" Second Button" />

< / form>


请注意,您的提交按钮没有名称属性。我添加了

一个,这样你就可以获取结果。现在,在test.php中,

Moses,

As others have said, you can do it with javascript, but many users have
javascript disabled.

However, you have the same target on both forms - you don''t need two
forms. You can do it with:

<form name="myform" action="test.php" method="post" >
<input type="text" name="myform_name" >
<input type="text" name="myform_id" >
<input type="text" name="myform_no" >
<input type="submit" name="Submit" value="First Button" />

<input type="text" name="myform1_name" >
<input type="text" name="myform1_id" >
<input type="text" name="myform1_no" >
<input type="submit" name="Submit" value="Second Button" />
</form>

Notice you didn''t have a name attribute for your submit button. I added
one so you can fetch the results. Now, in test.php,


这篇关于是否可以一次提交两个表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆