gpt4 book ai didi

php - 将表单元素分布在不同的网页中,看起来简单但无法修复

转载 作者:可可西里 更新时间:2023-10-31 23:33:47 25 4
gpt4 key购买 nike

这个问题与我之前的问题相似但不一样...请查看....我总共使用了 3 个网页;表单元素分布在“eg1.html”和“eg2.html”两个页面中,但是所有的表单元素都应该提交给“eg.php”。

 Here is the code for eg.php which accepts the form elements from both eg1.html and eg2.html:

$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"/>
<a href="eg2.html">click here to select other options which includes age and sex</a>
<input type="radio" name="label" value="stacks"/>
<input type="submit" name = "down" value = "down">
</form>
</body>

Now What would be the code for eg2.html? just check out sample partial html code :but needs to be compleated....

<input type="radio" name="age" value="3"/>
<input type="radio" name="sex" value="female"/>

代码应该完全像这样工作:第一个用户将打开 eg1.php 他只选择一个选项“fontsize”.. 接下来他单击“链接到 eg2.html”以选择另外两个选项“age”和“sex”...他将被重定向回 eg1.php,他必须在其中选择另一个选项“标签”...然后他将表单提交到 eg.php。它将包含所有表单元素,即“字体大小”、“年龄”、“性别”和“标签”......
我看到很多网站都使用这种技术,请查看 cooltext.com,用户可以选择点击字体图像,在选择其中一个字体图像后将他重定向到字体页面,他将被重定向回主页,在那里他可以选择其他一些表单元素或表单元素并最终提交表单....我也看到很多网站使用这种技术,我认为这可以使用 JQUERY/JavaScript 完成但不确定...请帮我解决这个问题问题 guyz,.,,,

最佳答案

使用 js 你可以将整个表单放在一个页面上,然后像这样分成几步

<form action="eg.php" method="post">
<div class="step1">
<input type="radio" name="fontsize" value="3"/>
<a href="#" id="step1_submit">click here to select other options which includes age and sex</a>
<input type="radio" name="label" value="stacks"/>
<input type="submit" name = "down" value = "down">
</div>
<div class="step2">
<a href="#" id="step2_back">click here to go back to step1</a>
<input type="radio" name="age" value="3"/>
<input type="radio" name="sex" value="female"/>
<input type="submit" value="Submit"/>
</div>
</form>

js:

$('#step1_submit').click(function(){
$('#step1').hide();
$('#step2').show();
});
$('#step2_back').click(function(){
$('#step1').show();
$('#step2').hide();
});

关于php - 将表单元素分布在不同的网页中,看起来简单但无法修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9278330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com