我有一项工作用于逐个显示测验问题,而在第3项中,它会说提交问题并计算所有值。所以, 第一页我加载了DB表数据并保存到会话变量。并使用一个iCounter和会话值显示问题。在按下按钮的同时,它调用quizQuestionNext.php文件并显示该阶段的值。下一步按钮不起作用:(。
我想要的是:
页-1
<div align="center" id="qestionDisplayBoard">
*emphasized text*
<form method='POST' name='quizForm'>
<table align="center" width='50%' border='0' class='questionDisplay'>
<input type='hidden' id='<?php echo "qPrimaryKey".$iCount;?>' value='<?php echo $_SESSION[$questionNo][0] ;?>' />
<tr bgcolor='#CCCCCC'><th> Question-<?php echo $iCount." : ".$_SESSION[$questionNo][1]; ?></th></tr>
<tr><td><label><input type='radio' name='<?php echo "Q".$iCount; ?>' value='<?php echo $_SESSION[$questionNo][2];?>'/><?php echo $_SESSION[$questionNo][2]?> </label></td></tr>
<tr><td><label><input type='radio' name='<?php echo "Q".$iCount; ?>' value='<?php echo $_SESSION[$questionNo][3];?>'/><?php echo $_SESSION[$questionNo][3]?> </label> </td></tr>
<tr><td><label><input type='radio' name='<?php echo "Q".$iCount; ?>' value='<?php echo $_SESSION[$questionNo][4];?>'/><?php echo $_SESSION[$questionNo][4]?> </label> </td></tr>
<tr><td><label><input type='radio' name='<?php echo "Q".$iCount; ?>' value='<?php echo $_SESSION[$questionNo][5];?>'/><?php echo $_SESSION[$questionNo][5]?> </label> </td></tr>
<tr><td><input type='hidden' id='<?php echo "participantAns".$iCount; ?>' value='<?php echo $_SESSION[$questionNo][6]?>'/></label> </td></tr>
</table>
</form>
</div>
<div align="center"><input class="divButton" type="button" value="| Next Question >>|" id="nextQuestion" onClick="questionDisplay('<?php echo $iCount; ?>')"></input></div>
<div align="center"><input class="divButton hideButton" type="button" value="| SUBMIT QUIZ >>|" id="submitQuiz" onClick="processResult()"></input></div>`
Page-2.php
`<?php session_start();
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
echo '<response>';
if($_SESSION['noq']<3)
{
$notEnough="NOt Enought Question";
echo $notEnough;
}
else
{
echo "<p>";
$iCount=$_POST['iCount'];
echo $_SESSION['participantQuestionId'][$iCount] = $_POST['participantQuestionId'];
echo "<br/>";
echo $_SESSION['participantQuestionResponse'][$iCount] = $_POST['participantQuestionResponse'];
echo "<br/>";
echo $_SESSION['participantActualAnswer'][$iCount] = $_POST['participantActualAnswer'];
echo "<br/>";
$iCount++;
echo $questionNo='questionNo'.$iCount;
echo "</p>";
?>
<form method='POST' name='quizForm'>
<table align="center" width='50%' border='0' class='questionDisplay'>
<input type='hidden' name='<?php echo "qPrimaryKey".$iCount;?>' value='<?php echo $_SESSION[$questionNo][0] ;?>' />
<tr bgcolor='#CCCCCC'><th> Question-<?php echo $iCount." : ".$_SESSION[$questionNo][1]; ?> ?</th></tr>
<tr><td><label><input type='radio' name='<?php echo "Q".$iCount; ?>' value='<?php echo $_SESSION[$questionNo][2];?>'/><?php echo $_SESSION[$questionNo][2]?> </label></td></tr>
<tr><td><label><input type='radio' name='<?php echo "Q".$iCount; ?>' value='<?php echo $_SESSION[$questionNo][3];?>'/><?php echo $_SESSION[$questionNo][3]?> </label> </td></tr>
<tr><td><label><input type='radio' name='<?php echo "Q".$iCount; ?>' value='<?php echo $_SESSION[$questionNo][4];?>'/><?php echo $_SESSION[$questionNo][4]?> </label> </td></tr>
<tr><td><label><input type='radio' name='<?php echo "Q".$iCount; ?>' value='<?php echo $_SESSION[$questionNo][5];?>'/><?php echo $_SESSION[$questionNo][5]?> </label> </td></tr>
<tr><td><input type='hidden' name='<?php echo "participantAns".$iCount; ?>' value='<?php echo $_SESSION[$questionNo][6]?>'/></label> </td></tr>
</table>
</form>`
`<?php
if (strpos($_SESSION[$questionNo][0],$_SESSION['quizName']) !== true)
{unset($_SESSION[$questionNo]);}
}
echo '</response>'; ?>`
页-3.js
`function questionDisplay(iCount)
{
qPk="qPrimaryKey"+iCount;
participantQuestionId = encodeURIComponent(document.getElementById(qPk).value);
qNo="Q"+iCount;
var pqrArray = document.getElementsByName(qNo);
for (var x = 0; x < pqrArray.length; x++)
{
if (pqrArray[x].checked)
{
var participantQuestionResponse = encodeURIComponent(pqrArray[x].value);
break;
}
}
ansNo="participantAns"+iCount;
participantActualAnswer = encodeURIComponent(document.getElementById(ansNo).value);
if(iCount==3) //show submit button if(iCounter==10)
{
document.getElementById("submitQuiz").className = "showButton";
document.getElementById("nextQuestion").className = "hideButton";
}
var allFormValues="iCount="+iCount
+ "&participantQuestionId="+participantQuestionId
+ "&participantQuestionResponse="+participantQuestionResponse
+ "&participantActualAnswer="+participantActualAnswer;
xmlHttp.open("POST", "quizQuestionNext.php",true);
xmlHttp.onreadystatechange=handleServerResponseForQuestionDisplay;
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.send(allFormValues);
}
function handleServerResponseForQuestionDisplay()
{
if (xmlHttp.readyState==4 && xmlHttp.status==200)
{
document.getElementById("qestionDisplayBoard").innerHTML=xmlHttp.responseText;
}
}`
我为这么长的帖子道歉。请建议任何可能的解决方案任何支持都非常感谢,并提前致谢