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"/> 代码应该像这样工作: 解决方法
使用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(); }); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |