一个按钮即可提交不同类型的字段 [英] submit different types of field from one single button

查看:54
本文介绍了一个按钮即可提交不同类型的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有四个Web表单,每个表单都有不同类型的字段,例如

Form1名称,年龄,位置,

关于您,城市,州的Form2

Form3 note1,note2…ect

Form4有一个提交"按钮和取消"按钮

然后用户将字段插入数据库中,然后跳过form3,然后转到form4,然后单击
没有请求..redirect();方法 .
如何将所有数据提交到数据库
就像是wedding.com,monster.com个人资料页面
怎么可能的,请回覆…….


[edit]从答案"转移到问题-OriginalGriff [/edit]

有什么办法可以做到这一点.我无法更改表单设计.我正在发送一个链接,您可以看到它类似于http://www.jeevansathi.com/profile/registration_pg1.php?source=hp_side表单太多了,我们该怎么做

I have four web forms and every form has different types of fields like

Form1 name,age, location,

Form2 about you , city, state

Form3 note1 ,note2 …ect

Form4 has a submit button ,and cancel button

And user inserts the fields into the database and he skips form3 and then he goes to the form4 and click
There is no request..redirect (); method .
How I can submit all data into the database
It is something like marriage.com, monster.com profile page
How it is possible please reply ……regards.


[edit]Transfered from "answer" to question - OriginalGriff[/edit]

Is there any way to do this job. i can not change the form design .i am sending one link you can see it is something like http://www.jeevansathi.com/profile/registration_pg1.php?source=hp_side there are so many forms so how we can do it

推荐答案

当他移至下一页时,请读取值并将其存储在Session中.
在页面的末尾,从Session中读取值,然后将其存储.
When he moves to the next page, read the values and store them in the Session.
At the end of the pages, read the values back form the Session, and store them.


我认为您的问题仅仅是表明您实际上需要一个单一的表单而不是Form1来表示.表格4.试想一下:您需要在单个HTTP请求中发布所有四种形式的所有数据.顺便说一句,整个请求不过是一个文本字符串,其中带有参数名称/值对.但这正是单个HTML表单的作用.

因此,您只需要重新设计页面并将所有四个或更多部分围成一种形式即可.

但是,您仍然可以在视觉上使四个部分区分开.要给人留下从Form3到Form4等的印象,您可以在多个<div>元素中制作四个或更多部分,并控制它们的可见性以通过一些导航控件(向前/向后,下一个/上一个).与这种方法一样,您只需要在客户端部分中进行操作,就可以使用jQuery,请参见:
http://en.wikipedia.org/wiki/JQuery [ http://jquery.com/ [ ^ ].

使用jQuery,这些事情真的很容易实现和维护.它看起来也非常紧凑.

如果您仍然需要四种不同的形式,则无论您做什么,它们都应该发送单独的HTTP请求.这是您可以考虑的相反变体.您应该在逻辑级别将它们集成在一起.这更加困难,因为您需要在每个步骤上维护会话.从技术上讲,所有帖子都是独立的,您需要确定它们来自同一用户,并将它们放在一起,并考虑跳过的表格,在其他步骤上发布的数据等.用户可能会犯错并能够继续前进返回当前零件是否通过您的验证.这种方法很常见.

—SA
I think that your problem is merely the indication that you actually need one single form instead of Form1 to Form4. Just think about it: you require in single HTTP request to post all data from all four forms. By the way, the whole request is nothing more but a text string with parameter name/value pairs written inside of it. But this is exactly what one single HTML form does.

So, you simply need to re-design your page and enclose all four or more parts in one form.

However, you still can make your four parts distinct visually. To make an impression of going from Form3 to Form4, etc., you can make four or more parts in, say, several <div> elements and control their visibility to show them one at a time with some navigation control (forward/back, next/previous). As with this approach you need to do it purely in a client part, I would use jQuery, please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com/[^].

With jQuery, such things are really easy to implement and maintain; it also looks very compact.

If you still want four separate forms, you should deal with the fact they send separate HTTP request anyway, no matter what you do. This is the opposite variant which you can consider. You should integrate them together on logical level. This is more difficult as you need to maintain the session on each step. Technically, all posts are independent, you need to identify that they come from the same user and put them together, take into account skipped forms, data which was post on other steps, etc. The user can make a mistake and be able to go back if the current part passed your validation or not. This approach is very usual.

—SA


这篇关于一个按钮即可提交不同类型的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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