Hello,
I have same Javascript that performs a little quiz after choose
selections from radio buttons. It displays the number of answer that
one got right. But it puts them in an alert box - I want it to be in
a new window.
The alert box works fine and show the correct data.
The button:
<input type=button onClick="Showto tal()" value="TOTAL">
Showtotal():
function Showtotal(){
var answerText = "What is the
total?\n------------------------------------\n";
for(i=1;i<=5;i+ +){
answerText=answ erText+"\nQuest ion :"+i+"\n";
if(ans[i]!=yourAns[i]){
answerText=answ erText+"\nThe correct answer was
"+ans[i]+"\n"+explainAn swer[i]+"\n";
}
else{
answerText=answ erText+" \nCorrect! \n";
score++;
}
}
[some code snipped]
alert(answerTex t); <---I want this data to show up in a new
window....
I tried adding :
var w = window.open('', 'mywin','width= 500,height=500' ); to my declared
variables
then instead of the alert box line, it was replaced with:
w.document.writ e('<html><head> <title>Choice </title></head><body><pre >'+answerText+' </pre></body></html>');
w.document.clos e();
w.focus();
</script>
What happens - when I open the original window - it opens up a blank
new windows with the orignal behind it. Pressing the TOTAL button
does nothing.
Help?
Thanks,
Tmuld.