PDA

View Full Version : if statement


beautyfiend
07-02-2009, 11:09 AM
Hi, Im sorry this is proberly really simple but I'm new to this.
My if statement isn't working, am I missing something in the code?
Any help much appreciated! Thank you.


<html>
<head>
<title>Which Video Game Character Are You?</title>
</head>
<body>
<div align="center"><img name="img1" src="which.png" width="300" height="300" border="0"></div>
<script language="JavaScript">
var myImages = new Array("taz.png", "sonic.png", "luigi.png", "crash.png", "mario.png");
var imgIndex = prompt("Enter a number from 0 to 4","");
if (number > 4)
{
alert("Number is too high");
}
document.images["img1"].src = myImages[imgIndex];
</script>
</body>
</html>

Cota
07-02-2009, 04:08 PM
Looks like you arent declaring 'number' anywhere..isnt imgIndex the number you want to check?

beautyfiend
07-02-2009, 04:43 PM
Looks like you arent declaring 'number' anywhere..isnt imgIndex the number you want to check?

Of course! Thank you.

Cota
07-02-2009, 04:51 PM
You are welcome.