Hi all,

I've got a page that has a button that takes the user to a results page (using Javascript), everything worked fine until I included another script for a countdown timer, now it says 'actualchoices' undefined, can anyone tell me what I'm doing wrong?

The part of the web page code that calls the scripts is:
<form>
<div align="center"> <input type="button" value="Score me" name="B1" onClick="gradeit()"><input type="button" value="Reset" name="B2" onClick="document.myquiz.reset()"></div></form>

AND

<input name="button" type="button" onClick="Down()" value="Begin Test" style="font-family:times new roman;size:10pt;">

The quiz script is:
//Enter total number of questions:
var totalquestions=20

//Enter the solutions corresponding to each question:
var correctchoices=new Array()
correctchoices[1]='a' //question 1 solution
correctchoices[2]='c' //question 2 solution, and so on.
correctchoices[3]='d'
correctchoices[4]='c'
correctchoices[5]='b'
correctchoices[6]='d'
correctchoices[7]='b'
correctchoices[8]='b'
correctchoices[9]='b'
correctchoices[10]='a'
correctchoices[11]='c'
correctchoices[12]='a'
correctchoices[13]='d'
correctchoices[14]='d'
correctchoices[15]='c'
correctchoices[16]='b'
correctchoices[17]='d'
correctchoices[18]='d'
correctchoices[19]='a'
correctchoices[20]='c'

/////Don't edit beyond here//////////////////////////

function gradeit(){
var incorrect=null
for (q=1;q<=totalquestions;q++){
var thequestion=eval("document.myquiz.question"+q)
for (c=0;c<thequestion.length;c++){
if (thequestion[c].checked==true)
actualchoices[q]=thequestion[c].value
}

if (actualchoices[q]!=correctchoices[q]){ //process an incorrect choice
if (incorrect==null)
incorrect=q
else
incorrect+="/"+q
}
}

if (incorrect==null)
incorrect="a/b"
document.cookie='q='+incorrect
if (document.cookie=='')
alert("Your browser does not accept cookies. Please adjust your browser settings.")
else
window.location="results.htm"
}



function showsolution(){
var win2=window.open("","win2","width=275,height=400, scrollbars")
win2.focus()
win2.document.open()
win2.document.write('<title>IT Principles Level 1 - Mock 1</title>')
win2.document.write('<body bgcolor="#FFFFFF">')
win2.document.write('<center><h4>Solution to IT Principles Level 1 - Mock 1</h4></center>')
win2.document.write('<center><font size=2><b>The answer(s) you got wrong are shown in <font color=red>RED</font></b></font></center><br>')
win2.document.write('<font size=2>For a more comprehensive list of the correct answers <a href="solution.htm" target="_blank">click here</a></font><br><br>')
win2.document.write('<center>')
for (i=1;i<=totalquestions;i++){
for (temp=0;temp<incorrect.length;temp++){
if (i==incorrect[temp])
wrong=1
}
if (wrong==1){
win2.document.write("Question "+i+"="+correctchoices[i].fontcolor("red")+"<br>")
wrong=0
}
else
win2.document.write("Question "+i+"="+correctchoices[i]+"<br>")
}
win2.document.write('</center>')

win2.document.close()
}

And the timer script is:
<!-- Begin

var up,down;

var min1,sec1;

var cmin1,csec1,cmin2,csec2;

function Minutes(data) {

for(var i=0;i<data.length;i++) if(data.substring(i,i+1)==":") break;

return(data.substring(0,i)); }

function Seconds(data) {

for(var i=0;i<data.length;i++) if(data.substring(i,i+1)==":") break;

return(data.substring(i+1,data.length)); }

function Display(min,sec) {

var disp;

if(min<=9) disp=" 0";

else disp=" ";

disp+=min+":";

if(sec<=9) disp+="0"+sec;

else disp+=sec;

return(disp); }

function Up() {

cmin1=0;

csec1=0;

min1=0+Minutes(document.sw.beg1.value);

sec1=0+Seconds(document.sw.beg1.value);

UpRepeat(); }

function UpRepeat() {

csec1++;

if(csec1==60) { csec1=0; cmin1++; }

document.sw.disp1.value=Display(cmin1,csec1);

if((cmin1==min1)&&(csec1==sec1)) alert("Stopwatch Stopped");

else up=setTimeout("UpRepeat()",1000); }

function Down() {

cmin2=1*Minutes(document.sw.beg2.value);

csec2=0+Seconds(document.sw.beg2.value);

DownRepeat(); }

function DownRepeat() {

csec2--;

if(csec2==-1) { csec2=59; cmin2--; }

document.sw.disp2.value=Display(cmin2,csec2);

if((cmin2==0)&&(csec2==0)) alert("Countdown Stopped");

else down=setTimeout("DownRepeat()",1000); }

// End -->


I know it's a lot of code but I thought it would be easier if I show all straight away.

Many thanks for any help, it's driving me insane!

colette