Click to See Complete Forum and Search --> : Tables, Scripting, and color changing... possible?


loftie
03-08-2009, 09:42 AM
To anyone who reads/helps, thank you in advance...

I was wondering if it were possible to change the color of a table row based on the how long the table row has existed?

Info... (Useless or useful...) I have a SharePoint server and it is setup at my work to allow co-workers to submit "forms" for information updates, etc. However these forms are not always checked in a timely manner. I was wondering if possible to change the bgcolor from the theme color to a color of my choice if the entry is there for more than say... an hour?

Am I even making sense? Haha. Hope so. Again, thanks in advance for reading & helping.

loftie
03-08-2009, 12:47 PM
Also:

I was looking into possibly using VBScript for this. We only use IE6.0 and do not have to worry about cross-browser functionality.

Fang
03-08-2009, 02:33 PM
Is there a date in the table row?

loftie
03-08-2009, 03:47 PM
Is there a date in the table row?

Date and timestamp. I was thinking of playing with 'if' and 'then' vbscripting... but my knowledge of vbscript is poor.

Fang
03-08-2009, 03:55 PM
Example table?

loftie
03-08-2009, 04:29 PM
Sloppy... hope it makes sense. Added 'NULL' where the original link was for obvious reasons.

Also, would just like to mention that the information is pulled/saved to InfoPath from the SharePoint...

<TD Class="ms-vb2">Not started</TD><TD Class="ms-vb2"><A onfocus="OnLink(this)" HREF="http://NULL/FollowUp%20Request/Updated_Info.xml" onclick="DispDocItemEx(this,'FALSE','FALSE','FALSE','')">Updated_Info</A><IMG SRC="/_layouts/1033/images/new.gif" alt="New"></TD><TD Class="ms-vb2">3/8/2009 16:22</TD><TD Class="ms-vb2">Information Update</TD></TR></TABLE></td></tr></table> <table width=100% cellpadding=0 cellspacing=0 border=0 > <tr> <td colspan="2" class="ms-partline"><IMG SRC="/_layouts/images/blank.gif" width=1 height=1 alt=""></td> </tr> <tr> <td class="ms-addnew" style="padding-bottom: 3px"> <img src="/_layouts/images/rect.gif" alt="">&nbsp;<a class="ms-addnew" ID="idAddNewForm" href="http://NULL/FollowUp%20Request/Forms/Upload.aspx?RootFolder=" ONCLICK="javascript:NewItem('http://northernsp/ctwest/Care_Comm/FollowUp%20Request/Forms/Upload.aspx?RootFolder=', true);javascript:return false;" target="_self">Add new form</a> </td> </tr> <tr><td><IMG SRC="/_layouts/images/blank.gif" width=1 height=5 alt=""></td></tr> </table></div></td></tr></table>

Charles
03-08-2009, 04:52 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example</title>
<style type="text/css">
tr.old-entry {background-color:#a00; color:#fff}
</style>

<script type="text/javascript">
Date.ONE_HOUR = 1000*60*60;

function update() {
var now = new Date(), i = 0, tr;
tbody = document.getElementsByTagName ('TBODY')[0];
while (tr = tbody.getElementsByTagName ('TR')[i++])
tr.className = now - new Date (tr.firstChild.firstChild.data) > Date.ONE_HOUR ? 'old-entry' : ''
}

if (document.getElementsByTagName) onload = function () {
update();
// setInterval ('update()', 100);
}
</script>
</head>
<body>
<table>
<thead>
<tr><th>Datetime</th><th>Giant Said</th></tr>
</thead>
<tbody>
<tr><td>8 March 2009 2:00 pm</td><td>Fee</td></tr>
<tr><td>8 March 2009 3:00 pm</td><td>Fie</td></tr>
<tr><td>8 March 2009 4:00 pm</td><td>Foe</td></tr>
<tr><td>8 March 2009 5:00 pm</td><td>Fum</td></tr>
</tbody>
</table>
</body>
</html>