T
Tavish Muldoon
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="Showtotal()" value="TOTAL">
Showtotal():
function Showtotal(){
var answerText = "What is the
total?\n------------------------------------\n";
for(i=1;i<=5;i++){
answerText=answerText+"\nQuestion :"+i+"\n";
if(ans!=yourAns){
answerText=answerText+"\nThe correct answer was
"+ans+"\n"+explainAnswer+"\n";
}
else{
answerText=answerText+" \nCorrect! \n";
score++;
}
}
[some code snipped]
alert(answerText); <---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.write('<html><head><title>Choice</title></head><body><pre>'+answerText+'</pre></body></html>');
w.document.close();
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.
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="Showtotal()" value="TOTAL">
Showtotal():
function Showtotal(){
var answerText = "What is the
total?\n------------------------------------\n";
for(i=1;i<=5;i++){
answerText=answerText+"\nQuestion :"+i+"\n";
if(ans!=yourAns){
answerText=answerText+"\nThe correct answer was
"+ans+"\n"+explainAnswer+"\n";
}
else{
answerText=answerText+" \nCorrect! \n";
score++;
}
}
[some code snipped]
alert(answerText); <---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.write('<html><head><title>Choice</title></head><body><pre>'+answerText+'</pre></body></html>');
w.document.close();
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.