If...else if- In this type of statement it executes the statement code following a condition that evaluates to true. If no condition evaluates to true then statement code following else gets executed
E.g.
If...else if statement
What's your grade?
Related Topics:
E.g.
<html>
<head>
<title>If...else if statement</title>
</head>
<body>
What's your grade?
<form>
Enter marks:<input name="stumarks" type="text" />
<input onclick="check(this.form)" type="button" value="Check" />
</form>
<script language="JavaScript">
function check(form)
{
if(form.stumarks.value>100)
{
alert("Not valid marks! Enter again")
}
else if(form.stumarks.value>89)
{
alert("Got grade A+")
}
else if(form.stumarks.value>79)
{
alert("Got grade A")
}
else if(form.stumarks.value>69)
{
alert("Got grade B+")
}
else if(form.stumarks.value>59)
{
alert("Got grade B")
}
else if(form.stumarks.value>39)
{
alert("Got grade C")
}
else if(form.stumarks.value>29)
{
alert("Got grade D")
}
else if(form.stumarks.value>0)
{
alert("Re-appear again")
}
else
{
alert("Unknown value")
}
}
</script>
</body>
</html>
Check Output:- JavaScript Introduction
- Variables in JavaScript
- JavaScript Function
- Accessing JavaScript Function
- Creating JavaScript interactive form
- Accessing form field value
- Creating interactive form login webpage
- Networking Fundamentals
- TCP/IP and Internet addressing
- Internet Working
- Internet Working Servers
- Concept and need for web publishing
- Web languages
- Javascript Control Structure
- Checking Text is Letter/s
- Checking Text is Number/s
- Checking Textbox is Empty or not
- Addition of two numbers
- Subtraction of two numbers
- Multiplication of two numbers
- Division of two numbers
- Form field validations
- Email validation