我有一个小的三页网站,其中每个页面都在div中,数据角色为" page" 我希望第三页显示结果。
表单页面div:
<div data-role="header">
<h2>Handle or Knob</h2>
<div data-role="navbar">
<ul>
<li><a href="#page1" class="ui-btn-active">Home</a></li>
<li><a href="#page2">Test</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /header -->
<div role="main" class="ui-content">
<form method="post" action="#page3">
<p>I enjoy the twists and turns in life</p>
<label>
<input name="radio-choice-0" id="radio-choice-0" type="radio" value="agree">Agree
</label>
<label>
<input name="radio-choice-0" id="radio-choice-1" type="radio" value="disagree">Disagree
</label>
<p>Cups are easier to use if they have a handle</p>
<label>
<input name="radio-choice-1" id="radio-choice-2" type="radio" value="agree">Agree
</label>
<label>
<input name="radio-choice-1" id="radio-choice-3" type="radio" value="disagree">Disagree
</label>
<p>Life pulls me in different directions sometimes</p>
<label>
<input name="radio-choice-2" id="radio-choice-4" type="radio" value="agree">Agree
</label>
<label>
<input name="radio-choice-2" id="radio-choice-5" type="radio" value="disagree">Disagree
</label>
<a href="#page3"><input type="submit" value="Results">
</form>
</div><!-- /content -->
<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->
结果页面div:
<div data-role="header">
<h1>Results</h1>
<div data-role="navbar">
<ul>
<li><a href="#page1" class="ui-btn-active">Home</a></li>
<li><a href="#page2">Test</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /header -->
<div role="main" class="ui-content">
<?php
$q1Answer = '';
$q2Answer = '';
$q3Answer = '';
$knobScore = 0;
$handleScore = 0;
$knobResult = '';
$handleResult = '';
$yourResult = '';
if(isset($_POST['submit'])){
$q1Answer = $_POST['radio-choice-0'];
$q2Answer = $_POST['radio-choice-1'];
$q3Answer = $_POST['radio-choice-2'];
echo $q1Answer;
echo $q2Answer;
echo $q3Answer;
}else{
echo "Please complete the form";
}
?>
</div><!-- /content -->
<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->
这是一项正在进行的工作,现在我只是想在结果页面上加载结果。然后我可以计算出得分。 谢谢你的时间。
答案 0 :(得分:0)
1。)action="#page3"
- &gt;如果提交应该返回到同一页面,只需删除action
属性,如果它应该指向另一个页面,则将该文件的全名包含在那里,例如action="page_3.php"
(但是肯定不是`action =“#page3”)。
2.。)不要试图验证提交,而是输入的内容:
if(isset($_POST['radio-choice-0']) && isset($_POST['radio-choice-1']) and isset($_POST['radio-choice-2'])){
....
}