日期:2014-05-16 浏览次数:20386 次
<table width="100%" border="1" class="listtable" id="table"> <tr class="listheader"> <td width="30" align="center" nowrap> 序号 </td> <td width="30" align="center" nowrap> <input type="checkbox" name="allbox" onclick="allboxclick()"> </td> <td width="30" align="center" nowrap> 编辑 </td> <td width="100" align="center" nowrap> <gpt:PageSortColumn column="obj.sn" htmlproperty="class='sortcolumn'">合同编号</gpt:PageSortColumn> </td> <td width="100" align="center" nowrap> <gpt:PageSortColumn column="obj.name" htmlproperty="class='sortcolumn'">合同名称</gpt:PageSortColumn> </td> <td width="100" align="center" nowrap> <gpt:PageSortColumn column="obj.money" htmlproperty="class='sortcolumn'">金额</gpt:PageSortColumn> </td> <td width="100" align="center" nowrap> <gpt:PageSortColumn column="obj.deadline" htmlproperty="class='sortcolumn'">期限</gpt:PageSortColumn> </td> <td width="100" align="center" nowrap> <gpt:PageSortColumn column="obj.principal" htmlproperty="class='sortcolumn'">负责人</gpt:PageSortColumn> </td> <td width="100" align="center" nowrap> <gpt:PageSortColumn column="obj.paytime" htmlproperty="class='sortcolumn'">付款时间</gpt:PageSortColumn> </td> </tr> <logic:iterate id="obj" name="OBJLIST" scope="request"> <tr class="listrow" onclick="hL(this)" onmouseout="out(this)"> <gpt:TD><%=++i%></gpt:TD> <td width="30" align="center"> <input type="checkbox" name="delbox" onclick="delboxclick();" value="<bean:write name="obj" property="id"/>" /> </td> <td width="30" align="center"> <img src="../../resources/images/icon/icon_modify.gif" class="icon" onclick="mod(400,380,<bean:write name='obj' property='id'/>);" /> </td> <bean:write name="obj" property="sn" /> <bean:write name="obj" property="name" /> <bean:write name="obj" property="money" /> <bean:write name="obj" property="deadline" /> <bean:write name="obj" property="principal" /> <bean:write name="obj" property="paytime" /> </tr> </logic:iterate> </table>
// 显示红色 window.onload = function(){ //得到这个表 var array = document.getElementById("table"); //得到这个表共有多少行 var length = array.rows.length - 1; var i=1; //循环判断是否超过付款日期 for(i=1; i <= length; i++){ var date = new Date(); var year = date.getFullYear(); var month = date.getMonth()+1; var day = date.getDate() - 1; //因为我这里是第7列,所以cells[6] var time = array.rows[i].cells[6]; var timeArray = new Array(); timeArray[0] = year; timeArray[1] = month; timeArray[2] = day; var j = 0; var k = 0; var subStrOfTime = time.innerText.substr(0,10); for(j = 0; j < subStrOfTime.split("-").length; j++){ var a = subStrOfTime.split("-")[j]; // 格式化后相比较 if(a.replace(/\b(0+)/gi,"")<=timeArray[j]) { k ++ ; } } if(k == 3){ array.rows[i].style.backgroundColor="#FF6900"; } }