
Dynamic Content In assignment #8, you saw that the current time could be dynamically printed to a web page using scripting. That same information can be used in conjunction with an IF THEN ELSE statement to create a dynamic "phrase" on a page. The "salutation" printed below is based on an IF THEN ELSE statement. If the current time is before noon, say "Good Morning", ELSE say "Good Afternoon". Good Afternoon
The above script first establishes a variable that equals the current time. This variable is called CurrentTime. The IF statement tests to see if CurrentTime is before noon. The "#" signs around the time indicate "time" data to the server. The "#" signs must be used around a time or date value. If the time is before noon, the first Response.Write line will be displayed. Response.Write is a method of writing something to the browser from inside a script. The same result could have been displayed by stopping the scripting after the THEN statement, as follows:
Sometimes you will not have the option of turning the scripting off, and the Response.Write command must be used. This is the case with the following page.
|