在JS中给单元格设置颜色

由于项目主样式限定不可给行设定样式,所以只能一个个单元格设置

 

.t1 {background-color:#ffff66}   //样式定义
.t11 {background-color:#ffff99}

var obj_Continued = document.all('oContinued_job');
var d1 = document.all('text');   //获取单元格对象
var obj_Continue_EndTime = document.getElementsByName('oContinue_EndTime');     
var theSecond = 24 * 60 * 60 * 1000 ;
var checkArray = new Array() ;     
var nowTime = '${currenttime}';
checkArray = nowTime.split("-");
nowTime = new Date(checkArray[0], checkArray[1], checkArray[2]);

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

  var checkDate = obj_Continue_EndTime[i].value;
  //alert(checkDate);2009-06-02 17:00:00.0,80853127
  var theOid = checkDate.substring( checkDate.lastIndexOf(",") + 1, checkDate.length );
  checkDate = checkDate.substring( 0, checkDate.indexOf(" ") );
  checkArray = checkDate.split("-");
  checkDate = new Date( checkArray[0], checkArray[1], checkArray[2]); // YYYY-MM-DD
 var diffTime = ( checkDate - nowTime ) / theSecond;
     
 if( diffTime == 1 ){
  for(var k=0; k<d1.length; k++) {
   if(d1[k].value==theOid) {
   d1[k].className = "t1";//设置满足条件的单元格的颜色样式
   }
  }
  for( j = 0; j < obj_Continued.length; j ++ ){
     if( obj_Continued[j].value == theOid ) {
      obj_Continued[j].color = "#000000";//设置字体颜色
     }
   }
 } else {
  for(var k=0; k<d1.length; k++) {
    if(d1[k].value==theOid) {
      d1[k].className = "t11";//不满足条件的使用另外的样式
     }
    }
   for( j = 0; j < obj_Continued.length; j ++ ){
     if( obj_Continued[j].value == theOid )
      obj_Continued[j].color = "#000000";//设置字体颜色
     }
  }
}

 

 

<!-- 序号 -->           
<td align="middle"  id="text" value="${continued_job.oid}">
 <font  id="oContinued_job" value="${continued_job.oid}"><ww:property value="#rowstatus.Index+1" /></font></td>
     
<!-- 站名 -->     
<td align="middle"  id="text" value="${continued_job.oid}">
 <font  id="oContinued_job" value="${continued_job.oid}"><ww:property value="stname"/></font></td>
     

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值