Image...

  • Thread starter Thread starter 116
  • Start date Start date
1

116

We have a page that contains links to many Qualitity documents. I would like
to have a PIC at the end of the link such as 'NEW', but only display for
Date() + 14. Not sure how to code this. Any help would be greatly
appreciated.

Thanks
David
 
Hi,
Assuming asp you can loop the files in a folder and do something depending
on the files last modified date, eg to show a "new" image for files younger
than 15 days
<%
Set fso = createobject("scripting.filesystemobject")
Set f = fso.getfolder(server.mappath("/YourFolder")).files
for each file in f
if datediff("d", file.datelastmodified, now) < 15 then
response.write file.name & "<img src=""new.gif""> <br>"
else
response.write file.name & "<br>"
end if
next
%>

Hopefully you can modify that to suit

Cheers,
Jon
 
Thank you for the quick response. The lniks on my page are merely typed.
Not a folder listing (like FTP would display I believe).

David
 
I use JAlbum on the site below, and it prints the word NEW for pictures for
files up to the creation date + X where X is user set , e.g. 30 days

I delved into the code and it uses this JavaScript
function generatenew(fDays) {
now = new Date();
nDays = now.getTime() / 86400000;
if((nDays - fDays) <= 30)
document.write('<span class="newlabel">&nbsp;NEW&nbsp;<\/span>&nbsp;');
}

It is used in the HTML like this
<script type="text/javascript">generatenew(14463);</script><a
href="slides/merc-bus-2004-01.html">1</a>
where 14463 is the date of creation set by JAlbum, but of course it can be
varied to suit.

For example,
if now = Sat Dec 19 10:32:58 UTC+1100 2009
nDays = 14596.981232997684

So by setting fDays to 14611 (14596 +15), the message will display for 15
days after Dec 19

See if this works for you
 
I forgot to add that the CSS for class="newlabel" is
..newlabel {
font-size: 70%;
font-weight: bold;
color: #eee;
background-color: #580;
}

You can either place this in the <head> section preceded by
<style type="text/css">
and followed by
</style>
or put it in a separate file, say "style.css", and call this file in the
<head> section by
<link rel="stylesheet" type="text/css" href="style.css">
 
Back
Top