Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, March 26, 2012

Color Based on Task Status for TD using JavaScript in a SharePoint List

<style>
.InProgress
{
    background-color:orange;
    font-size:x-small;
    font-weight:bold;
    color:white;
}
.NotStarted
{
    background-color:Red;
    font-size:x-small;
    font-weight:bold;
    color:white;

}
.Completed
{
    background-color:green;
    font-size:x-small;
    font-weight:bold;
    color:white;

}
.Deferred
{
    background-color:Navy;
    font-size:x-small;
    font-weight:bold;
    color:white;

}
.Waiting
{
    background-color:pink;
    font-size:x-small;
    font-weight:bold;
    color:white;

}




</style>
<script language="javascript" type="text/javascript">
 function getImagestoGrid()
{
                var rows = document.getElementsByTagName('td');
                 var numRows = rows.length;
                 for (var i = 0; i < numRows; i++)
                {
                                if(rows[i].innerHTML=="In Progress")
                                {
                                               //rows[i].innerHTML="<Img src='/Shared Documents/Research and Development/Images/In Progress.jpg' width='25' height='25' Title='In Progress'>";
                                               rows[i].className='InProgress';
       
                                }
                              
                                if(rows[i].innerHTML=="Completed")
                                {
                                                //rows[i].innerHTML="<Img src='/Shared Documents/Research and Development/Images/Completed.jpg' width='25' height='25' Title='Completed'>";
                                                rows[i].className='Completed';
                                }
                              
                                if(rows[i].innerHTML=="Deferred")
                                {
                                                //rows[i].innerHTML="<Img src='/Shared Documents/Research and Development/Images/Deferred.jpg' width='25' height='25' Title='Deferred'>";                
                                                rows[i].className='Deferred';
                                }
                               
                                if(rows[i].innerHTML=="Not Started")
                                {
                                                //rows[i].innerHTML="<Img src='/Shared Documents/Research and Development/Images/Not Started.jpg' width='25' height='25' Title='Not Started'>";                
                                                rows[i].className='NotStarted';
                                }
                               
                                  if(rows[i].innerHTML=="Waiting on someone else")
                                {
                                                //rows[i].innerHTML="<Img src='/Shared Documents/Research and Development/Images/Waiting on someone else.jpg' width='25' height='25' Title='Waiting on someone else'>";                
                                                rows[i].className='Waiting';
                                                rows[i].noWrap='noWrap';
                                }

                                //

                }               

}
_spBodyOnLoadFunctionNames.push("getImagestoGrid");</script>

No comments:

Post a Comment