If...else- In this type of statement if the condition is true then 1st written statement will get executed otherwise statement written after else will get executed.
E.g.1
E.g.2
If...else Statement
Are you qualified for voting?
Related Topics:E.g.1
<html>
<head>
<title>If...else Statement</title>
<script language="javascript">
var age=prompt("Enter Your Age");
if(age > 17)
{
alert("Qualified for voting")
}
else
{
alert("Not qualified for voting")
}
</script>
</head>
<body>
Are you qualified for voting?
</body>
</html>
E.g.2
<html>
<head>
<title>If...else Statement</title>
</head>
<body>
Are you qualified for voting?
<form>
Enter you age:<input name="usrage" type="text" />
<input onclick="check(this.form)" type="button" value="Check" />
</form>
<script language="javascript">
function check(form)
{
if(form.usrage.value > 17)
{
alert("Qualified for voting")
}
else
{
alert("Not qualified for voting")
}
}
</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