Dear All, can you pls help. I have the below code on my SharePoint 2007. My problem is that if I place this code above a SharePoint list does not calculate, if I put this under the list it calculates. Can you pls let me know how I could display the table above the list that would calculate the number of "On track" items.
=====
var x = document.getElementsByTagName("TD") // find all of the TDs
var Ont=0;
var i=0;
for (i=0;i<x.length;i++)
{
if (x[i].className=="ms-vb2") //find the TDs styled for lists
{
if (x[i].innerHTML=="On track")
{
Ont++
x[i].style.backgroundColor='palegreen'; // set the background color
x[i].style.color='Black'; //set the font color
}
The 'language=javascript' is the tip off that this is very old code as it has become deprecated.
You have displays between the '<td </td>' elements, which is also the incorrect syntax.
You are trying the change the contents of table elements with a class of 'ms-vb2'
but there is no class definition and it is not assigned to any of the elements in your script.
If you use document.write() statements anytime AFTER the page has been rendered initially,
it will reload the original code as if you had done nothing since the last earlier load.
Finally, you should check the error console if you are using FF or Chrome browsers to get a list of the errors.
BTW: You should use [ code] and [ /code] tags (without the spaces)
around you script to make it more readable on the forum and it preserves the spacing layout.
Bookmarks