User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,577 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,636 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 709 | Replies: 2
Reply
Join Date: Sep 2005
Location: St. Louis
Posts: 145
Reputation: kahaj is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
kahaj kahaj is offline Offline
Junior Poster

What am I missing here?

  #1  
Oct 26th, 2007
I had modified this from its original code. It was working before, but now it's not. I can't figure out what I'm missing here.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Dinosaur Quiz</title>

<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

//Question Scoring Function
function scoreQuestions(number, answer) {
	switch (number) {
		case 1:
			if (answer == 'b')
				window.alert("Correct Answer");
			else 
				window.alert("Incorrect Answer");
			break;
		case 2:
			if (answer == 'b')
				window.alert("Correct Answer");
			else 
				window.alert("Incorrect Answer");
			break;
		case 3:
			if (answer == 'c')
				window.alert("Correct Answer");
			else 
				window.alert("Incorrect Answer");
			break;
		case 4:
			if (answer == 'd')
				window.alert("Correct Answer");
			else 
				window.alert("Incorrect Answer");
			break;
		case 5:
			if (answer == 'a')
				window.alert("Correct Answer");
			else 
				window.alert("Incorrect Answer");
			break;
}

// STOP HIDING FROM INCOMPATIBLE BROWSERS-->
</script>

</head>
<body>

<h1>Dinosaur Quiz</h1>
<p>Answer all of the questions on the quiz, then select the Score button to grade the quiz. </p>
<form action="">
<p><b>1. What dinosaur was the heaviest?</b></p>
<p><input type="radio" name="question1" value="a"
     onclick="scoreQuestions(1, 'a')" />Tyrannosaurus<br />
<input type="radio" name="question1" value="b"
     onclick="scoreQuestions(1, 'b')" />Brachiosaurus<br /> <!-- correct answer -->
<input type="radio" name="question1" value="c"
     onclick="scoreQuestions(1, 'c')" />Brontosaurus<br />
<input type="radio" name="question1" value="d"
     onclick="scoreQuestions(1, 'd')" />Diplodocus</p>
<p><b>2. When did dinosaurs become extinct?</b></p>
<p><input type="radio" name="question2" value="a"
     onclick="scoreQuestions(2, 'a')" />1 billion years ago<br />
<input type="radio" name="question2" value="b"
     onclick="scoreQuestions(2, 'b')" />65 million years ago<br /> <!-- correct answer -->
<input type="radio" name="question2" value="c"
     onclick="scoreQuestions(2, 'c')" />10 million years ago<br />
<input type="radio" name="question2" value="d"
     onclick="scoreQuestions(2, 'd')" />15,000 years ago</p>
<p><b>3. Which of these is not a dinosaur?</b></p>
<p><input type="radio" name="question3" value="a"
     onclick="scoreQuestions(3, 'a')" />Megalosaurus<br />
<input type="radio" name="question3" value="b"
     onclick="scoreQuestions(3, 'b')" />Apatosaurus<br />
<input type="radio" name="question3" value="c"
     onclick="scoreQuestions(3, 'c')" />Pterodactyl<br />  <!-- correct answer -->
<input type="radio" name="question3" value="d"
     onclick="scoreQuestions(3, 'd')" />Triceratops</p>
<p><b>4. In which period did the Diplodocus live?</b></p>
<p><input type="radio" name="question4" value="a"
     onclick="scoreQuestions(4, 'a')" />Early Cretaceous<br />
<input type="radio" name="question4" value="b"
     onclick="scoreQuestions(4, 'b')" />Early Triassic<br />
<input type="radio" name="question4" value="c"
     onclick="scoreQuestions(4, 'c')" />Late Triassic<br />
<input type="radio" name="question4" value="d"
     onclick="scoreQuestions(4, 'd')" />Late Jurassic</p> <!-- correct answer -->
<p><b>5. Which of the following dinosaurs was a carnivore?</b></p>
<p><input type="radio" name="question5" value="a"
	onclick="scoreQuestions(5, 'a')" />Tyrannosaurus<br />  <!-- correct answer -->
<input type="radio" name="question5" value="b"
	onclick="scoreQuestions(5, 'b')" />Triceratops<br />
<input type="radio" name="question5" value="c"
	onclick="scoreQuestions(5, 'c')" />Stegosaurus<br />
<input type="radio" name="question5" value="d"
	onclick="scoreQuestions(5, 'd')" />Brontosaurus</p>

</form>
</body>
</html>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2007
Posts: 9
Reputation: Xavier2k is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
Xavier2k's Avatar
Xavier2k Xavier2k is offline Offline
Newbie Poster

Re: What am I missing here?

  #2  
Oct 26th, 2007
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Dinosaur Quiz</title>

<script type="text/javascript">


//Question Scoring Function
function scoreQuestions(number, answer) {
    switch (number) {
        case 1:
            if (answer == 'b')
                window.alert("Correct Answer");
            else 
                window.alert("Incorrect Answer");
            break;
        case 2:
            if (answer == 'b')
                window.alert("Correct Answer");
            else 
                window.alert("Incorrect Answer");
            break;
        case 3:
            if (answer == 'c')
                window.alert("Correct Answer");
            else 
                window.alert("Incorrect Answer");
            break;
        case 4:
            if (answer == 'd')
                window.alert("Correct Answer");
            else 
                window.alert("Incorrect Answer");
            break;
        case 5:
            if (answer == 'a')
                window.alert("Correct Answer");
            else 
                window.alert("Incorrect Answer");
            break;
        } // You missed this ;)
}

</script>

</head>
<body>

<h1>Dinosaur Quiz</h1>
<p>Answer all of the questions on the quiz, then select the Score button to grade the quiz. </p>
<form action="">
<p><b>1. What dinosaur was the heaviest?</b></p>
<p><input type="radio" name="question1" value="a"
     onclick="scoreQuestions(1, 'a')" />Tyrannosaurus<br />
<input type="radio" name="question1" value="b"
     onclick="scoreQuestions(1, 'b')" />Brachiosaurus<br /> <!-- correct answer -->
<input type="radio" name="question1" value="c"
     onclick="scoreQuestions(1, 'c')" />Brontosaurus<br />
<input type="radio" name="question1" value="d"
     onclick="scoreQuestions(1, 'd')" />Diplodocus</p>
<p><b>2. When did dinosaurs become extinct?</b></p>
<p><input type="radio" name="question2" value="a"
     onclick="scoreQuestions(2, 'a')" />1 billion years ago<br />
<input type="radio" name="question2" value="b"
     onclick="scoreQuestions(2, 'b')" />65 million years ago<br /> <!-- correct answer -->
<input type="radio" name="question2" value="c"
     onclick="scoreQuestions(2, 'c')" />10 million years ago<br />
<input type="radio" name="question2" value="d"
     onclick="scoreQuestions(2, 'd')" />15,000 years ago</p>
<p><b>3. Which of these is not a dinosaur?</b></p>
<p><input type="radio" name="question3" value="a"
     onclick="scoreQuestions(3, 'a')" />Megalosaurus<br />
<input type="radio" name="question3" value="b"
     onclick="scoreQuestions(3, 'b')" />Apatosaurus<br />
<input type="radio" name="question3" value="c"
     onclick="scoreQuestions(3, 'c')" />Pterodactyl<br />  <!-- correct answer -->
<input type="radio" name="question3" value="d"
     onclick="scoreQuestions(3, 'd')" />Triceratops</p>
<p><b>4. In which period did the Diplodocus live?</b></p>
<p><input type="radio" name="question4" value="a"
     onclick="scoreQuestions(4, 'a')" />Early Cretaceous<br />
<input type="radio" name="question4" value="b"
     onclick="scoreQuestions(4, 'b')" />Early Triassic<br />
<input type="radio" name="question4" value="c"
     onclick="scoreQuestions(4, 'c')" />Late Triassic<br />
<input type="radio" name="question4" value="d"
     onclick="scoreQuestions(4, 'd')" />Late Jurassic</p> <!-- correct answer -->
<p><b>5. Which of the following dinosaurs was a carnivore?</b></p>
<p><input type="radio" name="question5" value="a"
    onclick="scoreQuestions(5, 'a')" />Tyrannosaurus<br />  <!-- correct answer -->
<input type="radio" name="question5" value="b"
    onclick="scoreQuestions(5, 'b')" />Triceratops<br />
<input type="radio" name="question5" value="c"
    onclick="scoreQuestions(5, 'c')" />Stegosaurus<br />
<input type="radio" name="question5" value="d"
    onclick="scoreQuestions(5, 'd')" />Brontosaurus</p>

</form>
</body>
</html>

You missed '}' after your switch statement mate
Reply With Quote  
Join Date: Sep 2005
Location: St. Louis
Posts: 145
Reputation: kahaj is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
kahaj kahaj is offline Offline
Junior Poster

Re: What am I missing here?

  #3  
Oct 26th, 2007
Ah, thanks so much!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:18 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC