Quiz Script Help

wxdqz

New Member
I have been working on this script tonight and am having a heck of a time getting it to pass the value from a variable DisplayResult to the display(). It's just a simple script, here's the code below. I get a syntax error popup at line 75, which is a blank line. It occurs when I enter the <input type=hidden name=result> tag.

I need that tag to be there though so that document.quiz.result.value is defined.

Any help is much appreciated! (I have removed an irrelavant code that I know is not causing any errors)

<script language="JavaScript" type="text/javascript">
function display() {
DispWin = window.open('', 'NewWin',
'toolbar=no,status=no,width=300, height=200')
message = "Your results: <br>" + document.quiz.result.value;
DispWin.document.write(message);
}
</script>
<script language="javascript">
var quizScore = 0;

function CalculateScore(scoreBox, calcScore) {
if (scoreBox.checked == true) {
quizScore = quizScore + calcScore;
document.quiz.SCORE.value = quizScore;
}
else {
quizScore = quizScore - calcScore;
document.quiz.SCORE.value = quizScore;

}
}
</script>

<form name="quiz">
<p>1. Do you have many vivid memories from your early childhood?<br>
<input type="checkbox" name="qy1" value=http://www.webdeveloper.com/forum/archive/index.php/"ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn1" value="ON" onClick="CalculateScore(this, 0)">No
<p>2. Do you tend to lose yourself in movies, books, or TV shows?<br>
<input type="checkbox" name="qy2" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn2" value="ON" onClick="CalculateScore(this, 0)">No
<p>3. Do you tend to know what people are going to say before they say it?
<br><input type="checkbox" name="qy3" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn3" value="ON" onClick="CalculateScore(this, 0)">No
<p>4. Do powerful visual images ever trigger a physical senstaion in you? For example, do you feel thirsty during
the desert scenes in <i>Lawrence of Arabia</i>?
<br><input type="checkbox" name="qy4" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn4" value="ON" onClick="CalculateScore(this, 0)">No
<p>5. Have you ever zoned out while going somewhere and wondered how you'd gotten there?
<br><input type="checkbox" name="qy5" value=http://www.webdeveloper.com/forum/archive/index.php/"ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn5" value="ON" onClick="CalculateScore(this, 0)">No
<p>6. Do you sometimes think in images rather than in words?
<br><input type="checkbox" name="qy6" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn6" value="ON" onClick="CalculateScore(this, 0)">No
<p>7. Do you ever sense when someone has entered a room, even before seeing him?
<br><input type="checkbox" name="qy7" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn7" value="ON" onClick="CalculateScore(this, 0)">No
<p>8. Do you like to look at cloud shapes?
<br><input type="checkbox" name="qy8" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn8" value="ON" onClick="CalculateScore(this, 0)">No
<p>9. Do smells evoke powerful memories for you?
<br><input type="checkbox" name="qy9" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn9" value="ON" onClick="CalculateScore(this, 0)">No
<p>10. Have you ever been deeply moved by a sunset?
<br><input type="checkbox" name="qy10" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn10" value="ON" onClick="CalculateScore(this, 0)">No

<p>Score:&nbsp;
<input name=SCORE size="10" onFocus="window.focus()" onBlur="this.value=quizScore;">
<input type=hidden name=result>
<script language="javascript">

if (document.quiz.SCORE.value==0) || (document.quiz.SCORE.value==1) || (document.quiz.SCORE.value==2) {
DisplayResult = "Hypnosis may not be for you. You may find it hard to enter a trance and may have trouble responding to hypnotic suggestion.";
document.quiz.result.value = DisplayResult

} else
if (document.quiz.SCORE.value==3) || (document.quiz.SCORE.value==4) || (document.quiz.SCORE.value==5) ||
(document.quiz.SCORE.value==6) || (document.quiz.SCORE.value==7) {
document.quiz.result.value = "You're somewhere in the middle. While you should have no difficulty being hypnotized, you may not be susceptible to every suggestion.";

} else {
(document.quiz.SCORE.value==8) || (document.quiz.SCORE.value==9) || (document.quiz.SCORE.value==10)
document.quiz.result.value = "Not only will you have no problem going under, but you should respond well to most hypnotic suggestions. Who knows? Hypnosis may help you get through your next root canal.";
}


</script>

<p><input type="button" value=http://www.webdeveloper.com/forum/archive/index.php/"Get Results" onClick="display();"></p>
</form>
</body>
</html>
<html>
<head>
<title>Could You Be Hypnotized?</title>
</head>
<script language="JavaScript" type="text/javascript">
function display() {
DispWin = window.open('', 'NewWin',
'toolbar=no,status=no,width=300, height=200')
message = "Your results: <br>" + document.quiz.result.value;
DispWin.document.write(message);
}
</script>
</head>
<body>

<h1>Could you be hypnotized?</h1>
<p>This is taken from the March 2003 issue of Good Housekeeping Magazine. It is found on page 84.</p>
<p>The ability to be hypnotized is kind of like the ability to draw a picture or carry a tune: Some people
have it and some don't. It's estimated that only 5 percent of adults are unable to achieve any kind of hypnotic
state; the rest of us fall somewhere along a range of "hypnotizability." Curious to know if you'd be susceptible?
This quiz will give you an idea.</p>
<script language="javascript">
var quizScore = 0;

function CalculateScore(scoreBox, calcScore) {
if (scoreBox.checked == true) {
quizScore = quizScore + calcScore;
document.quiz.SCORE.value = quizScore;
}
else {
quizScore = quizScore - calcScore;
document.quiz.SCORE.value = quizScore;

}
}
</script>

<form name="quiz">
<p>1. Do you have many vivid memories from your early childhood?<br>
<input type="checkbox" name="qy1" value=http://www.webdeveloper.com/forum/archive/index.php/"ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn1" value="ON" onClick="CalculateScore(this, 0)">No
<p>2. Do you tend to lose yourself in movies, books, or TV shows?<br>
<input type="checkbox" name="qy2" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn2" value="ON" onClick="CalculateScore(this, 0)">No
<p>3. Do you tend to know what people are going to say before they say it?
<br><input type="checkbox" name="qy3" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn3" value="ON" onClick="CalculateScore(this, 0)">No
<p>4. Do powerful visual images ever trigger a physical senstaion in you? For example, do you feel thirsty during
the desert scenes in <i>Lawrence of Arabia</i>?
<br><input type="checkbox" name="qy4" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn4" value="ON" onClick="CalculateScore(this, 0)">No
<p>5. Have you ever zoned out while going somewhere and wondered how you'd gotten there?
<br><input type="checkbox" name="qy5" value=http://www.webdeveloper.com/forum/archive/index.php/"ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn5" value="ON" onClick="CalculateScore(this, 0)">No
<p>6. Do you sometimes think in images rather than in words?
<br><input type="checkbox" name="qy6" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn6" value="ON" onClick="CalculateScore(this, 0)">No
<p>7. Do you ever sense when someone has entered a room, even before seeing him?
<br><input type="checkbox" name="qy7" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn7" value="ON" onClick="CalculateScore(this, 0)">No
<p>8. Do you like to look at cloud shapes?
<br><input type="checkbox" name="qy8" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn8" value="ON" onClick="CalculateScore(this, 0)">No
<p>9. Do smells evoke powerful memories for you?
<br><input type="checkbox" name="qy9" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn9" value="ON" onClick="CalculateScore(this, 0)">No
<p>10. Have you ever been deeply moved by a sunset?
<br><input type="checkbox" name="qy10" value="ON" onClick="CalculateScore(this, 1)">Yes
<input type="checkbox" name="qn10" value="ON" onClick="CalculateScore(this, 0)">No

<p>Score:&nbsp;
<input name=SCORE size="10" onFocus="window.focus()" onBlur="this.value=quizScore;">
<input type=hidden name=result>
<script language="javascript">

if (document.quiz.SCORE.value==0) || (document.quiz.SCORE.value==1) || (document.quiz.SCORE.value==2) {
DisplayResult = "Hypnosis may not be for you. You may find it hard to enter a trance and may have trouble responding to hypnotic suggestion.";
document.quiz.result.value = DisplayResult

} else
if (document.quiz.SCORE.value==3) || (document.quiz.SCORE.value==4) || (document.quiz.SCORE.value==5) ||
(document.quiz.SCORE.value==6) || (document.quiz.SCORE.value==7) {
document.quiz.result.value = "You're somewhere in the middle. While you should have no difficulty being hypnotized, you may not be susceptible to every suggestion.";

} else {
(document.quiz.SCORE.value==8) || (document.quiz.SCORE.value==9) || (document.quiz.SCORE.value==10)
document.quiz.result.value = "Not only will you have no problem going under, but you should respond well to most hypnotic suggestions. Who knows? Hypnosis may help you get through your next root canal.";
}


</script>

<p><input type="button" value=http://www.webdeveloper.com/forum/archive/index.php/"Get Results" onClick="display();"></p>
</form>
</body>
</html>
 
Back
Top