Click to See Complete Forum and Search --> : separating result alerts


tecdoc5
06-20-2003, 12:53 PM
This code is for a project due in two days, I have to have popup boxes for two different buttons(submit and solutions).
I am posting the code that returns my needed info but it only works with one button and it is all on the same box. How can I separate the info?
I need total score under submit
and correct solutions under solutions.
I have all the other code set up for this.
Also in this code is the function engine () that is to return immediate feedback upon clicking the radio button. How do I need to write out this code to call the explanation for each question and not all questions together?
You can tell I am very new at this ! Help please.

function Engine(question, answer) {
yourAns[question]=answer; // give explanation for wrong answers
if (answer == ans[i]) {
alert ("Correct");
}
else {
alert(explainAnswer);
}
}


function CheckAns() { // submit button - show score
var CorrectNum = 0
}
function ShowAns(){ // solutions button - show all correct answers
var answerText ="";
for(i=1;i<=10;i++){
answerText=answerText+"\nQuestion :"+i+"\n"
if(ans[i]!=yourAns[i]){
answerText=answerText+"\nIncorrect!

"+explainAnswer[i]+"\n";
}
else{
answerText=answerText+" \nCorrect! \n";
score++;
}
}

answerText=answerText+"\n\nYour total score is :

"+score+" out of 10.\n";


alert(answerText);

}

tecdoc5
06-20-2003, 02:28 PM
ok I have revised enough code that i get most of my results, looks sloppy to me, though. However, when the user clicks a radio button in the quiz the explanation comes up for all of the wrong answers, one after the other. Can someone help with this code???

Please also tell me why I cant tally my score! Under Checkans

function Engine(question, answer) {
yourAns[question]=answer;
var answerText ="";
for(i=1;i<=10;i++){
answerText=answerText+"\nQuestion :"+i+"\n"
if(ans[i]!=yourAns[i]){
alert(answerText=answerText+"\nIncorrect! "+explainAnswer[i]+"\n");

}
else{
answerText=answerText+" \nCorrect! \n";
score++;
}
}
}


function ShowAns(question, answer) {
var ans="1.a 2.b 3.d 4.c 5.a 6.b 7.b 8.a 9.d 10.c";
alert(ans);
}
function CheckAns() {
var CorrectNum =0;
for(i=1;i<=10;i++){
if (yourAns==ans[i]);
score++;
}

alert(CorrectNum="\n\nYour total score is : "+score+" out of 10.\n");



}