`
xkahala
  • 浏览: 48638 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

在JS中给单元格设置颜色

    博客分类:
  • jsp
阅读更多

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

 

.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>
     

 

 

分享到:
评论
1 楼 wangdgsc 2009-12-14  
我比你幸福多了, 我基本上不搞前台css相关的东西

相关推荐

Global site tag (gtag.js) - Google Analytics