H I O X INDIA
Javascript Tutorial
Google
Web hscripts.com
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java-Script Tutorial
Introduction
Variables
Operators
Statements
Loops
Functions
Objects
Arrays
Browser Objects
Form DOM
Ask Your Doubts
Feedback





If Else Statement


Topic

What is the use of if-else statement?
How to use if else method in javascript?



Explanation

If-Else Statement:
        If else statement also has the same format as of "if" statement. Only additional thing is that an else part is added to if statement. So if the condition satisfies the statements inside if part will be executed else the statement inside else part will be executed
Syntax:
if(condition){
     // set of statements if condition satisfies
}
else{
     // set of statements if condition fails
}


Example Code:
<script language="javascript">
var a = "1234abc";
if(a == "adcdefa"){
        document.write(" inside if statement ");
}else{
        document.write(" inside else part of statement ");
}
</script>


Result:

In the above example the condition is to check if variable 'a' equals (==) "abcdefa". The condition fails as we have assigned a as "1234abc". So the else part is executed.


        Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

others

privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Other Links