Help - Search - Members - Calendar
Full Version: multiple if statements =/, My stupid program won't work =/
HTMLHelp Forums > Programming > Client-side Scripting
ngay
[spam links removed]

Here's my program, everything works perfectly except for those if statements
it only displays the first x output, the you fail one =/
any ideas?

<html>
<head>
<title> Control Structures </title>
<script language="javascript">
var fullname=null;
var mark,x=null;
var nl="<BR>"
fullname = prompt("Please enter your first and last name");
mark = prompt("Please enter your score in this course - ICS3M");
alert("Welcome to my Website" + " " + fullname + "\n" + " " + "Your score is" + " " + mark);
</script>
</head>
<body>
<center>
<h1>
<script language="javascript">
document.write("Hi" + " " + fullname +nl);
document.write("Your score is" + " " + mark +nl);
if((x>=0) && (x<50))
{
document.write("You are at level zero. You FAIL" + nl);
}
else if (x===50)
{
document.write("Your score is exactly PASSING");
}
else if((x>=50) && (x<60))
{
document.write("You are at level 1" + nl);
}
else if((x>=60) && (x<70))
{
document.write("You are at level 2" + nl);
}
else if((x>=70) && (x<80))
{
document.write("You are at level 3" + nl);
}
else if((x>=80) && (x<=100))
{
document.write("You are at the maximum level which is level 4" + nl);
}
else
{
document.write("YOU ENTERED INVALID RANGE OF SCORE" + nl);
}
</script>
</body>
</html>
Frederiek
You only declared "x" to be NULL.
Change the "x" in the if statements to "mark", or the other way around, change "mark" to "x" in the prompt and alert.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.