我根据http://techtrainingnotes.blogspot.com提供的信息使用javascript for SharePoint。问题是这是为一个SharePoint列表列而设计的,我需要它才能用于七列。我假设要做这项工作我需要让colDueDate成为一个数组。有人可以帮忙吗?
<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 :(得分: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';
}
}
}
}