calavera
04-08-2003, 02:32 AM
I'm try to create a multiple singe question page (3 here) that uses a frameset in the index (purpose of storing data). Using *.js the quesions/answers are stored via which the question page will read the data and create the content, with the form buttons containing an onclick. I've assigned a function name checkit(). Once the user finishes there will be a results page.
My problem is creating a script checkit() that will compare and store the users choice, from the question file to qfile.js, allowing me to produce the results at a later date. Once I've got 1 page working right I reckon I'll be able to finish it off.
If anyone can help I'd appreciate it! :)
Cheers!
Cal
Copy of the code is below:
qfile1.js
---------
var testname = "Testing"
var numquestions = 3
var questions = new Array (numquestions)
var choices = new Array (numquestions)
for (var i=0; i<=numquestions; i++) choices[i] = new Array(5)
var correctanswers = new Array (numquestions)
question[1] = "Q1. ......................?"
choice[1][1] = "q1 Test answer1"
choice[1][2] = "q1 Test answer2"
choice[1][3] = "q1 Test answer3"
choice[1][4] = "q1 Test answer4"
choice[1][5] = "q1 Test answer5"
correct[1] = 4
index.htm
---------
<HTML>
<HEAD><BASE TARGET="content">
<SCRIPT SRC="qfile1.js"> </SCRIPT></HEAD>
<script>
function checkit() {
???????????????
}
</script>
<FRAMESET COLS="100%,*">
<FRAME SRC="question01.htm" NAME="question01"></FRAME>
</FRAMESET>
</HTML>
question01.htm
--------------
<HTML>
<HEAD></HEAD>
<BODY>
<SCRIPT>
document.write("<H1>" + parent.testname + "</H1>")
document.write("<P>" + parent.numquestions + " questions</P>")
</SCRIPT>
<FORM name=form1>
<script>
document.write("<P>" + parent.question[1] + "<BR>")
</script>
a. <INPUT onclick=parent.checkit() type=radio value=a name=q1>
<script>
document.write(parent.choice[1][1] + "<BR>")
</script>
b. <INPUT onclick=parent.checkit() type=radio value=b name=q1>
<script>
document.write(parent.choice[1][2] + "<BR>")
</script>
c. <INPUT onclick=parent.checkit() type=radio value=c name=q1>
<script>
document.write(parent.choice[1][3] + "<BR>")
</script>
d. <INPUT onclick=parent.checkit() type=radio value=d name=q1>
<script>
document.write(parent.choice[1][4] + "<BR>")
</script>
e. <INPUT onclick=parent.checkit() type=radio value=e name=q1>
<script>
document.write(parent.choice[1][5] + "<BR>")
</script>
<P></FORM>
<A HREF="results.htm">results</A>
</BODY>
</HTML>
result.htm
----------
no content yet.
My problem is creating a script checkit() that will compare and store the users choice, from the question file to qfile.js, allowing me to produce the results at a later date. Once I've got 1 page working right I reckon I'll be able to finish it off.
If anyone can help I'd appreciate it! :)
Cheers!
Cal
Copy of the code is below:
qfile1.js
---------
var testname = "Testing"
var numquestions = 3
var questions = new Array (numquestions)
var choices = new Array (numquestions)
for (var i=0; i<=numquestions; i++) choices[i] = new Array(5)
var correctanswers = new Array (numquestions)
question[1] = "Q1. ......................?"
choice[1][1] = "q1 Test answer1"
choice[1][2] = "q1 Test answer2"
choice[1][3] = "q1 Test answer3"
choice[1][4] = "q1 Test answer4"
choice[1][5] = "q1 Test answer5"
correct[1] = 4
index.htm
---------
<HTML>
<HEAD><BASE TARGET="content">
<SCRIPT SRC="qfile1.js"> </SCRIPT></HEAD>
<script>
function checkit() {
???????????????
}
</script>
<FRAMESET COLS="100%,*">
<FRAME SRC="question01.htm" NAME="question01"></FRAME>
</FRAMESET>
</HTML>
question01.htm
--------------
<HTML>
<HEAD></HEAD>
<BODY>
<SCRIPT>
document.write("<H1>" + parent.testname + "</H1>")
document.write("<P>" + parent.numquestions + " questions</P>")
</SCRIPT>
<FORM name=form1>
<script>
document.write("<P>" + parent.question[1] + "<BR>")
</script>
a. <INPUT onclick=parent.checkit() type=radio value=a name=q1>
<script>
document.write(parent.choice[1][1] + "<BR>")
</script>
b. <INPUT onclick=parent.checkit() type=radio value=b name=q1>
<script>
document.write(parent.choice[1][2] + "<BR>")
</script>
c. <INPUT onclick=parent.checkit() type=radio value=c name=q1>
<script>
document.write(parent.choice[1][3] + "<BR>")
</script>
d. <INPUT onclick=parent.checkit() type=radio value=d name=q1>
<script>
document.write(parent.choice[1][4] + "<BR>")
</script>
e. <INPUT onclick=parent.checkit() type=radio value=e name=q1>
<script>
document.write(parent.choice[1][5] + "<BR>")
</script>
<P></FORM>
<A HREF="results.htm">results</A>
</BODY>
</HTML>
result.htm
----------
no content yet.