Go Back   I-Mockery Forum > I-Mockery Miscellaneous Forums > Questions, Suggestions, and Tech Support > guys, review my javascript 'cause it isn't working :(
FAQ Members List Calendar Today's Posts

Thread: guys, review my javascript 'cause it isn't working :( Reply to Thread
Title:
Message
Image Verification
Please enter the six letters or digits that appear in the image opposite.


Additional Options
Miscellaneous Options

Topic Review (Newest First)
Feb 10th, 2006 03:51 PM
bigtimecow
Quote:
<html>
<head>
<title>Adam Norton's Favorite Color Guessing Game</title>
</head>
<body>
<script language="Javascript">
<!--
var guessColor = prompt("What is Adam Norton's favorite color? (guess 1)","");
if (guessColor == "red")
{
alert("That is correctamundo! You are the master of guessing colors!");
document.write("<h1><font color=#FF0000>YOU GUESSED CORRECTLY!</font></h1>");
}
else
{
alert("That is incorrect! My favorite color is hotter than that...");
guessColor = prompt("What is Adam Norton's favorite color? (guess 2)","");
if (guessColor == "red")
{
alert("That is correctamundo! You are pretty good at guessing colors!");
document.write("<h1><font color=#FF0000>YOU GUESSED CORRECTLY!</font></h1>");
}
else
{
alert("That is incorrect! My favorite color reminds people of anger...");
guessColor = prompt("What is Adam Norton's favorite color? (guess 3 - the last!)","");
if (guessColor == "red")
{
alert("That is correctamundo! You aren't very good at guessing colors, but you got it!");
document.write("<h1><font color=#FF0000>YOU GUESSED CORRECTLY!</font></h1>");
}
else
{
alert("That is incorrect! Sorry, that was your final try. The correct answer is red.");
}
}
}

document.write("<h2>If you would like to play again, please press F5.</h2>");
//-->
</script>

</body>
</html>
yay it works (it looks really messy because there ain't no damn indentation here )

thank you achimp
Feb 10th, 2006 03:44 PM
bigtimecow well, now that i'm home (i was at school) i'll test it in mozilla
Feb 10th, 2006 01:18 PM
AChimp
Quote:
Originally Posted by bigtimebanned
ahh yes, you're right. what if i get rid of the "var" before each guessColor after the first declaration?
It might work after you do that.

The best way to debug Javascript is with Firefox and its javascript console. It'll tell you exactly what errors it encounters.
Feb 10th, 2006 01:17 PM
Esuohlim This reminds me of trying to learn MATLAB
Feb 10th, 2006 12:48 PM
bigtimecow ahh yes, you're right. what if i get rid of the "var" before each guessColor after the first declaration?
Feb 10th, 2006 11:03 AM
AChimp You're declaring guessColor multiple times, for starters.
Feb 10th, 2006 10:31 AM
bigtimecow jesus, i just started my class

ahh, but would that be the problem?
Feb 10th, 2006 10:28 AM
AChimp And HTML won't show up inside an alert box.
Feb 10th, 2006 10:26 AM
AChimp Good God that's the worst code I've ever seen. Look up for-loops.
Feb 10th, 2006 10:21 AM
bigtimecow
guys, review my javascript 'cause it isn't working :(

Quote:
<html>
<head>
<title>Adam Norton's Favorite Color Guessing Game</title>
</head>
<body>
<script language="Javascript">
<!--
var guessColor = prompt("What is Adam Norton's favorite color? (guess 1)","");
if (guessColor == "red")
{
alert("That is correctamundo! You are the master of guessing colors!");
document.write("<h1><font color="red">YOU GUESSED CORRECTLY!</font></h1>");
}
else
{
alert("That is incorrect! My favorite color is hotter than that...");
var guessColor = prompt("What is Adam Norton's favorite color? (guess 2)","");
if (guessColor == "red")
{
alert("That is correctamundo! You are pretty good at guessing colors!");
document.write("<h1><font color="red">YOU GUESSED CORRECTLY!</font></h1>");
}
else
{
alert("That is incorrect! My favorite color reminds people of anger...");
var guessColor = prompt("What is Adam Norton's favorite color? (guess 3 - the last!)","");
if (guessColor == "red")
{
alert("That is correctamundo! You aren't very good at guessing colors, but you got it!");
document.write("<h1><font color="red">YOU GUESSED CORRECTLY!</font></h1>");
}
else
{
alert("That is incorrect! Sorry, that was your final try. The correct answer is red.");
}
}
}

document.write("<h2>If you would like to play again, please press F5.</h2>");
//-->
</script>

</body>
</html>

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

   


All times are GMT -4. The time now is 08:38 AM.


© 2008 I-Mockery.com
Powered by: vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.