Hi, im trying to make a quiz in which we can alternate b/w 2 questions for now....The thing im trying to do is that suppose we're on question 1, we answer and proceed to question 2, when i come back to question 1, that answer should be visible in the text box, however, this code is nt giving me any response text, could u please help me out?

im certain the problem is when im calling the saveAnswer(id, readText(this.form)) function in the html...please help!

<script type="text/javascript">

	answers = new Array();

function showQuestion(id)
		if(id == "" || id == null)
			document.getElementById("question").innerHTML = "Please select the question";
			var answerHTML = "<form id='test' onSubmit='return false;'><input type='text' name='qans' value='" + displaySavedAnswer(id) + "'><button type='button' name='submit' onClick='"+saveAnswer(id, readText(this.form))+"'>Save Answer</button></form>";
			xmlhttp = new XMLHttpRequest();
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.onreadystatechange = function()
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
						document.getElementById("question").innerHTML = xmlhttp.responseText;
						document.getElementById("answer").innerHTML = answerHTML;
		xmlhttp.open("GET", "process.php?id="+id, true);
function saveAnswer(id, form)
		var answer = form.qans.value;
		answers[id] = answer;
function displaySavedAnswer(id)
		return answers[id];


<form action="">
<select name="qid" onchange="showQuestion(this.value)">
<option value="">Select a Question:</option>
<option value="1">1</option>
<option value="2">2</option>

<div id="question"></div>
<div id="answer"></div>


readText appears to be a function, but where is it defined ? Not sure, but maybe you don't need it.