Hi i'm new to this so ok I have a simple
XHTML form with 8 radio button options for each question, I have 20 questions, each is pulled from an
XML file. I have managed to construct the JavaScript to validate that an option has to be selected but I need a way to store each questions answer when you move onto the next question, maybe as a string or an array??? Please help!!! Thanks.
<?
xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<
html xmlns="
http://www.w3.org/1999/
xhtml">
<head>
<link href="style.
css" rel="stylesheet" type="text/
css" />
<
xml id="staffInfo" src="questions.
xml"></
xml>
<title>MonsterSurvey</title>
<script language="javascript" type="text/javascript">
<!--
function submitIt(survey){
//Checks question/answer radio button
answerOption = -1
for (i=0; i<survey.answer.length; i++){
if (survey.answer[i].checked){
answerOption = i
}
}
if(answerOption == -1){
alert("You need to select an answer on the scale of 1-7 or N/A");
return false;
}
return true;
}
// -->
</script>
</head>
<body>
<form action="
http://www.cknuckles.com/
cgi/echo.
cgi" method="post" name="survey" onsubmit="return submitIt(this)">
<table width="770">
<tr>
<td colspan="9"><span datasrc="#staffInfo" datafld="question"></span></td>
<tr>
<td width="190"><statement>Not at all true of me</statement></td>
<td width="50" align="center"><answer> 1</answer></td>
<td width="50" align="center"><answer>2</answer></td>
<td width="50" align="center"><answer>3</answer></td>
<td width="50" align="center"><answer>4</answer></td>
<td width="50" align="center"><answer>5</answer></td>
<td width="50" align="center"><answer>6</answer></td>
<td width="50" align="center"><answer>7</answer></td>
<td width="50" align="center"><answer>N/A</answer></td>
<td width="190"><statement>Very true of me</statement></td>
</tr>
<tr>
<td> </td>
<td align="center"><input type="radio" name="answer" value="1" /></td>
<td align="center"><input type="radio" name="answer" value="2" /></td>
<td align="center"><input type="radio" name="answer" value="3" /></td>
<td align="center"><input type="radio" name="answer" value="4" /></td>
<td align="center"><input type="radio" name="answer" value="5" /></td>
<td align="center"><input type="radio" name="answer" value="6" /></td>
<td align="center"><input type="radio" name="answer" value="7" /></td>
<td align="center"><input type="radio" name="answer" value="NA" /></td>
</tr>
</table>
<button onclick="staffInfo.recordset.moveNext();
if (staffInfo.recordset.EOF) staffInfo.recordset.moveFirst()">Next Question</button>
<br /><br />
<input type="submit" value="Submit Answers" />
</form>
</body>
</
html>