Display image if time elapsed is less than 24hours

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adelemb
    New Member
    • Feb 2008
    • 6

    Display image if time elapsed is less than 24hours

    Hi all,

    I want an image to display in a table if another table cell shows an updated date of less than 24hours. The date displayed in the cell is already working and display fine, but I have no idea where to start with calling the image!

    This is to be used on a forum that displays a list of posted messages in a table. If a new message is posted under a topic, then I want an image to display for that topic indicating that there is something new - like a star or similar. We already have a table cell that displays the last updated date and time. Can I use this cell information to set up a bit of javascript to display the image? Or should I be using another coding language? Can it be done?

    I can usually sort stuff like this out myself with a bit of online research but I need somewhere to start!

    I can supply more info if needed, thanks for any help!!

    Adele x
  • tswaters
    New Member
    • Feb 2007
    • 19

    #2
    PHP Forum? If so, probably way easier to do on the server-side of things. if you wanted to do it with javascript ... creating the image is simple enough, do this in global scope:

    [code=javascript]
    newImage = document.create Element("IMG");
    newImage.src = "new.png"; newImage.border ="0"
    [/code]

    but then where to put it's clones? you'd have to first, find elements where dates are stored, parse their text into dates, compare those dates with the current date to confirm it's < 24 hours.... finally, once you've confirmed you have an element of which contains a date < 24 hours ago -- you can do something like:

    [code=javascript]
    elem.parentNode .insertBefore( newImage.cloneN ode(true) , elem )
    [/code]

    and that will make something like
    [html]
    <div id="imaparent" >
    <span>2008-02-13</span> <img src="new.png" border="0">
    </div>
    [/html]

    Comment

    Working...