Link to home
Start Free TrialLog in
Avatar of Westside2004
Westside2004Flag for United States of America

asked on

Showing user an image dynamically for a day?

Hi,

I wanted to see if someone can help with this issue.

I wanted to add this small feature for our site.  Basically when a user creates a new document in our web based app, we show the user a list of the documents associated with their account in a nice html table.  Their documents are listed as hyperlinks.

I want to display a simple image on my page that has the words "new" on it next to the hyperlink if the document was created "today".  So for the whole day the user would see the *New* image next to the hyperlink.

The next day when the user logs in, the new image would be gone as it would be the next day.

How can I accomplish this?  Does it involve client variables or would it be done through a cookie?  If user does not accept cookies, what alternatives are there?  It is my understanding that client variables compare the information from a db or a registry to a cookie on the users machine so if the user does not have cookies enabled, what does the client var in our db compare itself to???

Thanks,

West



Avatar of Seth_Bienek
Seth_Bienek


Hey West,

All you need is the age of the document.

Wether it's a file or a record in a database, there should be a date associated with it's creation.  Use that date to determine wether the 'new' graphic gets displayed or not:

<cfif datediff(userdocument.date_added, now()) LTE 0><img src="/images/new.gif"></cfif>

Something like that.

Regards,

Seth
Avatar of Westside2004

ASKER

Yes, that makes sense..

Will try what you gave me..

I am basically looking to show the image if the document is 6 hours old or less, if so, mark it new by showing the new img

Otherwise, don't show any image at all..

Thanks

-West
ASKER CERTIFIED SOLUTION
Avatar of Seth_Bienek
Seth_Bienek

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
HI,

Will try it now..

What is the "h"?
Avatar of pinaldave
Hi Westside2004,
seth has good suggestion. h stands for hour. As you are looking for six hours difference.

Regards,
---Pinal
Ok..

I thought that... but wanted to just make sure...

Thanks

-Westside