使用两个网页提交表单值
我一共有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 的链接.html
在 eg1.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据你想如何处理这个问题,你可以
缓存在服务器,您可能需要使用临时文件或数据库。这很麻烦,但好处是用户可以做一半,去吃晚饭,然后回来继续。
要将数据传递到第二页,您可以选择使用
location.hash
在提供给下一页的链接中附加该信息。或者,您可以使用 cookie。第三个也比较容易实现。每个页面使用
div
或iframes
并让顶部文档保存数据。Depending on how you want to handle this, you can
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
oriframes
for each page and have the top document hold the data.