加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 在不同的网页之间分发表单元素,看起来很简单但无法修复

发布时间:2020-12-13 16:15:03 所属栏目:PHP教程 来源:网络整理
导读:这个问题类似于我之前的问题,但不一样……请查看….我正在使用totaly 3个网页;表单元素分布在两个页面“eg1.html”和“eg2.html”中,但所有表单元素都应提交给“eg.php”. Here is the code for eg.php which accepts the form elements from both eg1.html
这个问题类似于我之前的问题,但不一样……请查看….我正在使用totaly 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”选择两个选项“年龄”和“性别”后选择…他将被重定向回eg1.php,他必须再选择一个“标签”选项…然后他将表格提交给eg.php.哪个将包含’fontsize”年龄”性’和’标签’的所有表单元素…..
我见过许多使用这种技术的网站请查看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();
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读