Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Enterprise
Expertise: Beginner
Oct 19, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Display Greeting Message

Here is a simple way by which you can display a greeting message to a user at the time of login.There are certain scenarios where you can use this feature to provide a welcome message to the user, such as in case of a online book or music store.

In the following example function PrintGreetingMessage() takes in a user name and displays a message depending upon the time of the web server. The statement <%= PrintGreetingMessage("User Name") %> sends the return value of the function to the browser. Thus, a user viewing this page before 12:00 noon (in the Web server's time zone) would see following text:

Good Morning !!! "User Name"
And a user viewing the same page at or after 12:00 noon would see following text:
Hello !!! "User Name"
You can write some additional code to get the "User Name" using cookies, etc.
<%@ Language=VBScript %>
<HEAD><TITLE>Display Greeting Message</TITLE></HEAD>
function PrintGreetingMessage(strUserName)
 dim strGreetingMessage

 ' Set a message depending upon the time
 if (Time >= #12:00:00 AM# and  Time < #12:00:00 PM#) then
  strGreetingMessage = "Good Morning !!! "
  strGreetingMessage = "Hello !!! "
 end if
 ' return the message out to the HTML page
 PrintGreetingMessage = strGreetingMessage & strUserName
end function

<%= PrintGreetingMessage("User Name") %>
Deepak Pant
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date