ASP   «Prev  Next»

ASP Course Project - Exercise

Use variables and functions to add interactivity


Objective:Use ASP variables and functions in an HTML page.

Scoring

This exercise is worth a total of 10 points.
To receive full credit, you will need to correctly create the ASP code to make the message change appropriately.
Once you have completed your answer you will submit your answer.

Background/overview

Many commercial Web sites display messages of new products or special sales on the Home (or main or default) Page of the site.
If a static message (a simple text string) is used to announce a sale with a firm ending date, someone has to remember to change the message several times in several days from a simple announcement to an "Ending soon!" message to a "Last day of sale!" message to a "Watch for our next sale" message.
Would not it be more efficient, and less subject to human error, to create some sort of programmed decision to display the several versions of the sale message automatically?
The lessons in this module contain all the information you will need.

Instructions

In the Default.asp page of the course project, you will find an area of code commented out that refers to the Module 2 course project exercise.
Create an ASP script and input or copy it into this area so that it will display when a user reaches the Project site's Home Page.

This script should display one of several messages depending on the current date and end-of-sale date:
  1. If the sale is still running but it is not the last day, this message should be displayed:

Do not miss out on our End of Season sale! This sale must
end on [date in the future]!

  1. If it is the last day of the sale, this message should be displayed:

Hurry! Our End of Season sale ends today! Don't be left out!
  1. If the sale is over, this message should be displayed:

You just missed our End of Season sale! 
Watch for news of our next sale!

Message to Display

The decision of which message to display would seem to be based upon whether the current date is less than, equal to, or less than the ending date of the sale, which you can store in a variable. To test your code without waiting for days to pass, you can put different sale end dates in the variable to simulate the three conditions and run the default.asp page in your browser.
You should follow proper scripting practices by making your variable names and your code easy for another programmer to understand and follow.

Submitting your exercise

Enter (or copy and paste) your ASP script into the text box below. It is not necessary to copy in the entire default.asp page. Click the Submit button to submit the code.