2014-04-22 152 views
0

我使用javascript for SharePoint根據http://techtrainingnotes.blogspot.com提供的信息。問題是這是爲一個SharePoint列表列設計的,我需要它爲七列工作。我假設做這個工作我需要colDueDate一個數組。有人可以幫忙嗎?將數組傳遞給childNode

<script type="text/javascript" language="javascript"> 

var colDueDate = 3;//single column 

var i=0; 
d=new Date(); //current date/time 
var x = document.getElementsByTagName("TD") // find all of the TDs 
for (i=0;i<x.length;i++) 
{ 
if (x[i].className=="ms-vb2") //find the TDs styled for lists 
{ 
    if (Date.parse(x[i].parentNode.childNodes[colDueDate].childNodes[0].innerHTML)<d.getTime()) 
    { 
     x[i].parentNode.childNodes[colDueDate].style.backgroundColor='red'; // set the color 
     } 
    } 
} 
</script> 

回答

0

盲目飛行:

var 
colDueDate = [3, 4, 5, 6, 7...], 
j = 0, i = 0, 
tr, td, c, 
d = new Date(), 
x = document.getElementsByTagName("TD"); 

for (i = 0; i < x.length; i++) { 

    if (x[i].className == "ms-vb2") { 
    tr = x[i].parentNode; 

    for (j = 0; j < colDueDate.length; j++) { 
     td = tr.childNodes[colDueDate[j]]; 
     c = td.childNodes[0]; 

     if (Date.parse(c.innerHTML) < d.getTime()) { 
     p.style.backgroundColor = 'red'; 
     } 
    } 

    } 
} 
+0

使用你的建議,極大的幫助讓我在正確的方向。對於(j = 0; j user3561365