if else in javascript :-
Syntax:
if(condition)
{
//code for execution;
}
else
{
//code for execution;
}
if condition is true then code written in his body execute, otherwise else’s code execute.
Example:
<HTML>
<HEAD>
<SCRIPT LANGUAGE=”JavaScript”>
<!–
<>function password() {
<>pass = prompt(’Type the word education’,”");
<>if(pass==”education”) {
location = ‘lession 2.html’;
}
else
{
alert(”Please try again”);
}
}
// –>
</SCRIPT>
</HEAD>
<BODY>
<A href=”javascript:password()”>
<IMG src=”pict.gif” NAME=”pic1″ ALT=”about us!” BORDER=”0″ align=”left”> </A>
<H3>Click the image to enter a password protected document. Try a wrong entry first.</H3>
</BODY>
</HTML>
