Wednesday 4 July 2012

Ex10: If & Else statement in VBScript


IF..Then..Else Statement
<!DOCTYPE html>
<html>


<head>
<script type="text/vbscript">
Function greeting()
i=hour(time)
If i < 10 Then
 document.write("Good morning!")
Else
 document.write("Have a nice day!")
End If
End Function
</script>
</head>


<body onload="greeting()">
</body>


</html>


IF..Then..ElseIf Statement

<!DOCTYPE html>
<html>


<head>
<script type="text/vbscript">
Function greeting()
i=hour(time)
If i = 10 Then
document.write("Just started...!")
ElseIf i = 11 Then
document.write("Hungry!")
ElseIf i = 12 Then
document.write("Ah, lunch-time!")
ElseIf i = 16 Then
document.write("Time to go home!")
Else
document.write("Unknown")
End If
End Function
</script>
</head>


<body onload="greeting()">
</body>


</html>

No comments:

Post a Comment