javascript
Brief description  about Online courses   join in Online courses
View Humphrey  Ocansey 's Profile

MY LOOP STATEMENT IS NOT WORKING

<script language = "javaScript">
Age = document.frmOne.cmbAge.value
switch (select){
case 0:
alert("still at school");
break;
case 1:
alert("still young");
break;
case 2:
alert("start lying");
break;
case 3:
alert("start saving");
break;
default:
alert("undetermined");
}
</script>
Please this was my code for the "Loop" but it is not working in any of my browsers. Sir,please what may be the possible cause of this problem and this is why i have not been able to get to the other Lessons.Please help me.Thank you
Asked by Humphrey Ocansey | Sep 7, 2013 |  Reply now
Replies (2)
View Humphrey Ocansey 's Profile
Sir, please this code works perfectly and i have submitted the assignment on it but right now i am talking of the switch statement
Sep 11, 2013
View Teacher SiliconIndia 's Profile
Hi Humphrey Ocansey

You try this example it will work ...........

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="Naveen Siwas" />
<title>javascript grade</title>
</head>

<body>

<script type="text/javascript">
function my_function(){

var num= document.loopform.chk_num.value;
if (num >=90 && num<=100) {
alert("You scored A Grade");
}
else if (num >=80 && num<=89) {
alert("You scored B Grade");
}
else if (num >=70 && num<=79) {
alert("You scored C Grade");
}
else if (num >=60 && num<=69) {
alert("You scored D Grade");
}
else if (num >=50 && num<=59) {
alert("You scored E Grade");
}
else{
alert("You scored F Grade");
}

}

</script>

<div align="center">
<form name="loopform">
Enter any number to check your grade : <input type="text" size="30" name="chk_num" />
<input type="button" value="Check Grade" onclick="return my_function();" />
</form>
</div>

</body>
</html>
Sep 8, 2013