tanneman
10-01-2002, 10:25 AM
Hi everybody
My name is Tanju and I am still learning javascript. As I was working on a script I bumped into a little problem. I have to make an E-learning site. Very simple acctually but the problem is whenever the user clicks on the correct answer a textbox which starts with the value "0" must increase with 1...This textbox is placed into an other frame because every question is a different plage.
This is the code that I used to make the quiz:
var ans = new Array; //those are the correct answers
ans[1] = "b";
ans[2] = "a";
ans[3] = "c";
ans[4] = "a";
ans[5] = "c";
//this loads when I click on a radiobutton of the multiple choice quiz
function MyCheck(question, answer, page){
if (answer == ans[question]) {
parent.question.location='question'+page+'.html';
for (i=0;i<parent.tellen.document.score.juiste.length;i++){
//now I don't know what to do...
//parent.tellen.document.score.juiste.value =
}
} else {
parent.question.location='question'+page+'.html';
}
}
so, everything works except the increasing of the value in the textbox...
___________________________________________
This is the body code:
<form name="quiz" method="post" action="">
<br>
<p>
<span class="tmain2">1. De gevaren van gassen</span><br>
<span class="tmain">1.1 Verstikkingsgevaar</span></p>
<table cellspacing="0" cellpadding="0" border="0">
<tr><td width="47">
<td valign="middle" class="tmain" colspan="5" >1. Hoeveel zuurstof omvat de omgevingslucht?
<tr><td width="47" height="20"> <td width="24" height="20"><input type="radio" name="chosen" value="a" onclick="MyCheck(1, this.value, 2)"><td height="20" class="tmain" colspan="4"> 11%
<tr><td width="47" height="20"> <td height="20"><input type="radio" name="chosen" value="b" onclick="MyCheck(1, this.value, 2)"><td class="tmain" height="20" colspan="4">21%
<tr><td width="47" height="20"> <td height="20"><input type="radio" name="chosen" value="c" onclick="MyCheck(1, this.value, 2)"><td class="tmain" height="20" colspan="5"> 31%
<tr><td width="47" height="20"> <td height="20" align="center" valign="bottom">
<td width="316" height="20" colspan="3" align="left" valign="middle" class="tablebody2">
<div id="oef1Msg"></div>
</table>
</form>
____________________________________
And this is the body code of the Textbox put into a different frame
<form name="score" >
<br><span class="tmain">score:</span> <input type="text" size="8" value="0" name="juiste" style="FONT-SIZE: 9px; COLOR: #ffffff; FONT-FAMILY: verdana, geneva, arial, helvetica; background-color:#2E356C"></form>
_______________________________________
Many Thanks
Best regards
My name is Tanju and I am still learning javascript. As I was working on a script I bumped into a little problem. I have to make an E-learning site. Very simple acctually but the problem is whenever the user clicks on the correct answer a textbox which starts with the value "0" must increase with 1...This textbox is placed into an other frame because every question is a different plage.
This is the code that I used to make the quiz:
var ans = new Array; //those are the correct answers
ans[1] = "b";
ans[2] = "a";
ans[3] = "c";
ans[4] = "a";
ans[5] = "c";
//this loads when I click on a radiobutton of the multiple choice quiz
function MyCheck(question, answer, page){
if (answer == ans[question]) {
parent.question.location='question'+page+'.html';
for (i=0;i<parent.tellen.document.score.juiste.length;i++){
//now I don't know what to do...
//parent.tellen.document.score.juiste.value =
}
} else {
parent.question.location='question'+page+'.html';
}
}
so, everything works except the increasing of the value in the textbox...
___________________________________________
This is the body code:
<form name="quiz" method="post" action="">
<br>
<p>
<span class="tmain2">1. De gevaren van gassen</span><br>
<span class="tmain">1.1 Verstikkingsgevaar</span></p>
<table cellspacing="0" cellpadding="0" border="0">
<tr><td width="47">
<td valign="middle" class="tmain" colspan="5" >1. Hoeveel zuurstof omvat de omgevingslucht?
<tr><td width="47" height="20"> <td width="24" height="20"><input type="radio" name="chosen" value="a" onclick="MyCheck(1, this.value, 2)"><td height="20" class="tmain" colspan="4"> 11%
<tr><td width="47" height="20"> <td height="20"><input type="radio" name="chosen" value="b" onclick="MyCheck(1, this.value, 2)"><td class="tmain" height="20" colspan="4">21%
<tr><td width="47" height="20"> <td height="20"><input type="radio" name="chosen" value="c" onclick="MyCheck(1, this.value, 2)"><td class="tmain" height="20" colspan="5"> 31%
<tr><td width="47" height="20"> <td height="20" align="center" valign="bottom">
<td width="316" height="20" colspan="3" align="left" valign="middle" class="tablebody2">
<div id="oef1Msg"></div>
</table>
</form>
____________________________________
And this is the body code of the Textbox put into a different frame
<form name="score" >
<br><span class="tmain">score:</span> <input type="text" size="8" value="0" name="juiste" style="FONT-SIZE: 9px; COLOR: #ffffff; FONT-FAMILY: verdana, geneva, arial, helvetica; background-color:#2E356C"></form>
_______________________________________
Many Thanks
Best regards