Page content

P

Philip WATTS

I am having trouble in understanding some page presentation.
I have copied some Javascipt from a book and am trying to develope it.
It is basicly a quiz, and when you get to the end you have the option to
restart or submit your result via email.
I am working on the latter problem, but to satrt with am trying simply to
get the script to re-present the score in the browser.

What I do not understand is why/how the original script function (endQuiz)
presents a page with the pageHeading from my remote js file and uses my css
style sheet format, while the function that I have introduced (send) does
not. This function starts a new page with no refernce to the js file or css
file.

I cannot see what difference there is in the two areas of script.

Both appear to be functions laid out in the header in the same way.

Sorry this is a bit long winded, but any help would be welcome

The relevant parts of the script are:-

1. The function (endQuiz) in the original script

function endQuiz() {
document.writeln('<form name="finsihedForm">')
document.write("<h4 align='center'>")
document.write("Congradulations! You have finsihed this Quiz.")
document.writeln('<br><br><input type="button" name="restart"
value="Restart"')
document.writeln('onClick="restartQuiz()">')
document.writeln('<input type="button" name="submit" value="Submit score"')
document.writeln('onClick="send()">')
document.writeln("</h4>")
document.writeln('</form>')
}

2. The function that I have inserted

function send() {
document.writeln('<form name="sendform">')
document.write("Well done, please enter your e-mail address")
document.write('</form>')
}

3. And from the body of the document, the main code calling the relevant
endQuiz function

<body>
<script language="javascript">
readCookie()
document.writeln("<h1 align='center'>"+pageHeading+"</h1>")
document.writeln("<p
align='right'><b>Questions/Attempts:"+numberOfQuestions+"<br>")
document.writeln("Correct Answers: "+correctAnswers+"<br>")
document.writeln("Score: "+score+" </b></p>")
if(currentQuestion>=qa.length) endQuiz()
else askNextQuestion()
// --></script>
</body>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,162
Latest member
GertrudeMa
Top