简体   繁体   English

如何将常用输入用于两种形式?

[英]how to use common inputs for two forms?

i want to create landing page which has two form one for login and another foe register. 我想创建登录页面,登录页面有两种形式,一种用于登录,另一种用于仇敌注册。 but my design is like as following fig.(i try to explain in this fig.) and i want use nested form. 但是我的设计就像下面的图(我试图在这个图中解释),我想使用嵌套形式。 login form is inside registration form. 登录表格位于注册表格内。

when user click on login submit data to login.jsp and for register button submit to register.jsp 当用户单击登录时,将数据提交到login.jsp,对于注册按钮,将数据提交到register.jsp

i know nested form is not possible in html but any other method available in JavaScript or jsp so i can implement this functionality. 我知道html中不可能使用嵌套形式,但是JavaScript或jsp中可用的任何其他方法都可以,因此我可以实现此功能。

so i want to use these email and password inputs for login form and also for registration form also. 所以我想将这些电子邮件和密码输入用于登录表单以及注册表单。

 __________________________________________
|                                          |
|  ___________________________             |
| |                           |            |
| |                           |            |
| |  email                    |            |
| |                           |            |
| |                           |            |
| |                           |  Login     |
| |                           |            |
| |  password                 |            |
| |                           |            |
| |                           |            |
| |___________________________|            |
|                                          |
|                                          |
|  First Name                              |
|                                          |
|                                          |
|  Last Name                               |
|                                          |
|                                          |
|  Birth Day                               |
|                                          |
|                 Register                 |
|__________________________________________|

Thank You. 谢谢。

Use a single form which submits to user.jsp and branch based on which submit button ( <input type="submit" name="login" value="Login"> or <input type="submit" name="register" value="Register"> ) appears in the submitted data. 使用单个表单提交到user.jsp并根据哪个提交按钮进行分支( <input type="submit" name="login" value="Login"><input type="submit" name="register" value="Register"> )出现在提交的数据中。

Ignore all the fields you don't care about if the Login branch is followed. 如果遵循了Login分支,请忽略所有您不关心的字段。

Forms should not be nested. 表单不应嵌套。 It goes against the html5 working draft . 它违反了html5工作草案

4.10.3 The form element 4.10.3 form元素

Content model: 内容模型:

Flow content, but with no form element descendants. 流内容,但没有表单元素后代。

You could create two separate forms, with hidden email & password fields in the latter one. 您可以创建两个单独的表单,在后一个表单中具有隐藏的电子邮件和密码字段。 Then attach a function that copies those fields from one form to the other when user clicks register -button. 然后附加一个函数,当用户单击register按钮时,会将这些字段从一种形式复制到另一种形式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM