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