当每个收音机都从两个问题中检查时,我正在尝试重定向。但我使用的以下代码不起作用。
function chekcSubmitType()
{
if(document.getElementById('ra').checked, document.getElementById('rc').checked)
{
window.location="page-1.html";
}
if(document.getElementById('ra').checked, document.getElementById('rd').checked)
{
window.location="page-2.html";
}
if(document.getElementById('rb').checked, document.getElementById('rc').checked)
{
window.location="page-3.html";
}
if(document.getElementById('rb').checked, document.getElementById('rd').checked)
{
window.location="page-4.html";
}
}
我使用 JavaScript 代码将这两个问题分开。
<form name="myquiz" method="post">
<p>Question (1)</p>
<span>500</span>
<input type="radio" id="ra" value="question1"/>
<span>1000</span>
<input type="radio" id="rb" value="question1"/>
<!--I have separated these both by using a JavaScript code-->
<p>Question (2)</p>
<span>1500</span>
<input type="radio" id="rc" value="question2"/>
<span>2000</span>
<input type="radio" id="rd" value="question2"/>
<input type="button" onClick="chekcSubmitType()" value="Go" />
</form>
这是我真正想做的:
(r) 代表无线电
ra + rc redirect to page-1.html
ra + rd redirect to page-2.html
rb + rc redirect to page-3.html
rb + rd redirect to page-4.html