如何使用两种形式并提交一次? [英] How to use two forms and submit once?

查看:101
本文介绍了如何使用两种形式并提交一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有两个表单有两个提交按钮,当我点击按钮时,它将输入字段保存在两个表单中?



我很在意在PHP / MySQL中解决这个问题。



我尝试了我自己的方式:

 <$ c $($ set $($ _ POST [form-1]))&&(isset($ _ POST [form-2])){
// SQL插入
}


解决方案

不能,您只能提交一个表单时间。

如果您必须使用两种形式,唯一的方法是使用jQuery将第二种形式的字段复制到第一种形式中。当关闭JS时。



请参阅



为什么你需要两种表单?


Is it possible to have two forms with two submit buttons such that when I click on the button it saves the input fields in both forms?

I'm concerning to solve this in PHP / MySQL.

I tried my own way:

if ((isset($_POST["form-1"])) && (isset($_POST["form-2"])) {
    //SQL Insertion 
}

解决方案

Nope, you can only submit one form at a time.

If you have to use two forms, the only way to do this would be to clone the second form's fields into the first one using jQuery. Won't work when JS is turned off, though.

See Copying from form to form in jQuery

Why do you need two forms?

这篇关于如何使用两种形式并提交一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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