Java Script Conditional Statement
IF... ELSE Statement:
The if/else statement executes a block of code if a specified condition is true ther wise false.
_____________________________________________________
IF ..... ELSE IF.....
Example:
<script type="text/javascript">
var a=parseInt(prompt("Enter No A",""));
var b=parseInt(prompt("Enter No B",""));
if(a<b)
{
document.write("A Is Less Then Of 20 <br>");
}
else if(a==b)
{
document.write("A is equal to B <br>");
}
else if(a<50)
{
alert("hello");
}
else
{
alert("this is a alert box");
}
</script>
__________________________________________________________
Switch Statement using Java Script:
Example:
<script type=text/javascript>
var d=new Date();
abc=d.getDay();
a = parseInt(prompt("enter Switch",""));
switch (a)
{
default:
alert("no case define");
break;
case 0:
document.write("Hello");
break;
case 1:
document.write("Monday");
break;
case 2:
document.write("welcome");
break;
case 3:
document.write(" Tamene Game e rakho");
break;
case 4:
document.write("Sleepy THUS");
break;
case 5:
document.write("Sleepy FRI");
break;
case 6:
alert("end of");
break;
}
</script>
___________________________________________________________
Learn All programming and Scripting languages with youtube.com/avadhtutor/
Nice Blog, it is very impressive.
ReplyDeleteLearn Java Online
Java Training Institute in Chennai
Java Training Institutes in Bangalore