Ticker

6/recent/ticker-posts

JavaScript (Else If Statement)

JAVASCRIPT ELSE IF STATEMENT

The Else If statement is used to insert two or more than two conditions.



EXAMPLE 1: Program to find grade by entered marks
<html>
<title> Grading System </title>
<body>
<form name="f">
Enter your marks <input type="text" name="marks">

<input type="button" value="Find Grade" onclick="grade()">
</form>

<script>
function grade()
{
var m;
m=f.marks.value

if (m>=33 && m<50)
alert("C Grade");

else if (m>=50 && m<75)
alert("B Grade");


else if (m>=75 && m<=100)
alert("A Grade");


else if (m<33)
alert("You have failed");

else
alert("Invalid marks");
}
</script>
</body>
</html>







Post a Comment

0 Comments