使用两个网页提交表单值

发布于 2025-01-05 08:40:20 字数 1281 浏览 2 评论 0原文

我一共有3页;表单元素分布在两个页面“eg1.html”和“eg2.html”中,但表单元素提交到“eg.php”。

以下是 eg.php 的代码

$size=$_POST["fontsize"];
$label=$_POST["label"];
$age=$_POST["age"];
$sex =$_POST["sex"];

eg1.html 的代码

 <html> 
 <body> 
 <form action="eg.php" method="post"> 
 <input type="radio" name="fontsize" value="3"/> 
 <link to eg2.html>
 <input type="radio" name="label" value="stacks"/> 
 <input type="submit" name = "down" value = "down"> 
 </form> 
 </body>

eg2.html 的代码

 <html> 
 <body> 
 <form action="eg.php" method="post">
 <input type="radio" name="age" value="18"/> 
 <input type="radio" name="sex" value="female"/> 
 <input type="submit" name = "down" value = "down"> 
 </form> 
 </body> 
 </html>

我已添加指向 eg2 的链接.htmleg1.html 中。这意味着用户首先将打开 eg1.html;他将在提交表单元素之前选择表单元素,他将获得一个指向 eg2.html 的链接;一旦他点击该链接,他将被重定向到eg2.html。

eg2.html 中,他应该能够选择其他表单元素,选择后他将被重定向回 eg1.html,在那里他将能够提交所有表单eg.php 元素 [其中包括eg1 和eg2]

我见过很多网站使用这种技术。

I have a total of 3 pages; form elements are distributed among two pages, "eg1.html" and "eg2.html", but the form elements are submitted to "eg.php".

Here is the code for eg.php:

$size=$_POST["fontsize"];
$label=$_POST["label"];
$age=$_POST["age"];
$sex =$_POST["sex"];

code for eg1.html

 <html> 
 <body> 
 <form action="eg.php" method="post"> 
 <input type="radio" name="fontsize" value="3"/> 
 <link to eg2.html>
 <input type="radio" name="label" value="stacks"/> 
 <input type="submit" name = "down" value = "down"> 
 </form> 
 </body>

code for eg2.html

 <html> 
 <body> 
 <form action="eg.php" method="post">
 <input type="radio" name="age" value="18"/> 
 <input type="radio" name="sex" value="female"/> 
 <input type="submit" name = "down" value = "down"> 
 </form> 
 </body> 
 </html>

I have added a link to eg2.html in eg1.html. That means that first the user will open eg1.html; he will select the form elements before submitting the form elements he will be provided with a link to eg2.html; once he clicks on the link, he will be redirected to eg2.html.

In eg2.html he should be able to select other form elements, and after selecting he will be redirected back to eg1.html, where he will be able to submit all form elements to eg.php [which includes both eg1 and eg2]

I have seen many websites using this tecniques.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小傻瓜 2025-01-12 08:40:20

根据你想如何处理这个问题,你可以

  1. 让服务器缓存前半部分响应
  2. 将数据传递到要一起提交的第二页
  3. 将它们放在 1 页中,并使其看起来像 2 页

缓存在服务器,您可能需要使用临时文件或数据库。这很麻烦,但好处是用户可以做一半,去吃晚饭,然后回来继续。

要将数据传递到第二页,您可以选择使用 location.hash 在提供给下一页的链接中附加该信息。或者,您可以使用 cookie

第三个也比较容易实现。每个页面使用 diviframes 并让顶部文档保存数据。

Depending on how you want to handle this, you can

  1. Let the server cache the first half of the response
  2. Pass the data along to the second page to be submitted together
  3. Put them in 1 page, and make it look like 2 pages

To cache on the server, you'll probably need to use temp files or a database. This is very cumbersome, but the upside is that the user can do half of it, go for dinner, and come back to continue.

To pass the data along to the second page, you can choose to attach that information in the link provided to the next page, using location.hash. Alternatively, you can use cookies.

The third one is also relatively easy to accomplish. Use divs or iframes for each page and have the top document hold the data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文