bradz1993
03-13-2012, 01:34 PM
javascript2.js
function displayMessage(msg) {
// Open a new window
var msgWindow = window.open('', 'Message');
// Write message in the new Window
msgWindow.document.write(msg);
// Raise this window, in case it's not visible
msgWindow.focus();
}
//Enter total number of questions:
var totalquestions=13
var correctchoices=new Array("a","a","b","c","b","c","a","a","b","c","a","b","b");
var correctanswers=new Array("memory locations","_ underscore","x=5+5;","20","Else","lose win","ticker = ticker + 1;","Ticker = ticker + 1;","300.000","Jonathon \b","var","var counter;","var mark = 50, 70");
function gradeit(){
var actualchoices=new Array()
var msg1=new Array()
var correctanswersno=0
var t=0
var displaycorrectanswers=""
for (q=1;q<=totalquestions;q++){
var thequestion=eval("document.Questionform.q"+q)
for (c=0;c<thequestion.length;c++){
if (thequestion[c].checked==true)
actualchoices[q]=thequestion[c].value
}
if (actualchoices[q]==correctchoices[q]){
msg1[t]=q+")"+" Correct";
correctanswersno = correctanswersno + 1;
t = t + 1;
} else {
msg1[t]=q+")"+" Incorrect: <br>Correct Answer: "+correctchoices[q]+") "+correctanswers[q];
t = t + 1;
}
}
for (p=0;p<=12;p++){
displaycorrectanswers+="<br>"+msg1[p];
}
var msg="Score: "+correctanswersno+"/"+totalquestions+" <br><br>Marks: "+displaycorrectanswers;
displayMessage(msg);
}
Basically on my index page it has a button which when clicked makes use of gradeit(). Currently this then used displayMessage(msg) which opens a new window and displays the message.
However, what I want it to do is to open another created html page e.g. answer.html and then for this page to display the message. How do i do this?
function displayMessage(msg) {
// Open a new window
var msgWindow = window.open('', 'Message');
// Write message in the new Window
msgWindow.document.write(msg);
// Raise this window, in case it's not visible
msgWindow.focus();
}
//Enter total number of questions:
var totalquestions=13
var correctchoices=new Array("a","a","b","c","b","c","a","a","b","c","a","b","b");
var correctanswers=new Array("memory locations","_ underscore","x=5+5;","20","Else","lose win","ticker = ticker + 1;","Ticker = ticker + 1;","300.000","Jonathon \b","var","var counter;","var mark = 50, 70");
function gradeit(){
var actualchoices=new Array()
var msg1=new Array()
var correctanswersno=0
var t=0
var displaycorrectanswers=""
for (q=1;q<=totalquestions;q++){
var thequestion=eval("document.Questionform.q"+q)
for (c=0;c<thequestion.length;c++){
if (thequestion[c].checked==true)
actualchoices[q]=thequestion[c].value
}
if (actualchoices[q]==correctchoices[q]){
msg1[t]=q+")"+" Correct";
correctanswersno = correctanswersno + 1;
t = t + 1;
} else {
msg1[t]=q+")"+" Incorrect: <br>Correct Answer: "+correctchoices[q]+") "+correctanswers[q];
t = t + 1;
}
}
for (p=0;p<=12;p++){
displaycorrectanswers+="<br>"+msg1[p];
}
var msg="Score: "+correctanswersno+"/"+totalquestions+" <br><br>Marks: "+displaycorrectanswers;
displayMessage(msg);
}
Basically on my index page it has a button which when clicked makes use of gradeit(). Currently this then used displayMessage(msg) which opens a new window and displays the message.
However, what I want it to do is to open another created html page e.g. answer.html and then for this page to display the message. How do i do this?