var Td_BackGround_Color_Array = Array(); var Td_Font_Color_Array = Array(); //選中後RD的顏色和字體的顏色 var Change_BackGround_color ="#4684c1"; var Change_Font_color ="#ffffff"; //下面兩色為原始的背景色和原始字的顏色 var Old_BackGround_Color = "#ffffff"; var Old_Font_color = "#000000"; //-------------------------------------- //設置行的換色 var Tr_Change_BackGround="#72a3cf"; var Tr_Change_Fontcolor="#ffffff";
var Cell_Selected_Array = Array();
function Init_Table_Tr_Td(Table_id){ var Table_Object = document.all.item(Table_id); var Table_Tr_Length = parseInt(Table_Object.rows.length); var Table_Td_Length = parseInt(Table_Object.rows[1].cells.length);
Td_BackGround_Color_Array[i][y] = Table_Object.rows[i].cells[y].style.background; Td_Font_Color_Array[i][y] = Table_Object.rows[i].cells[y].style.color; }// END FOR Y }// END FOR I }
//設置列的顏色 function Change_TdBgColor(me,Table_Object){ var tdobject = me; while(tdobject.tagName!="TD"){tdobject = tdobject.parentElement;} var tdindex = tdobject.cellIndex; var Table_Tr_Length = parseInt(Table_Object.rows.length); var Table_Td_Length = parseInt(Table_Object.rows[0].cells.length);
for(var i=1;i<Table_Tr_Length;i++){ if(Table_Object.rows[i].cells[tdindex].style.background==Td_BackGround_Color_Array[i][tdindex]){ Table_Object.rows[i].cells[tdindex].style.background=Change_BackGround_color; Table_Object.rows[i].cells[tdindex].style.color=Change_Font_color; Cell_Selected_Array.push(tdindex); }else{ Table_Object.rows[i].cells[tdindex].style.background=Td_BackGround_Color_Array[i][tdindex]; Table_Object.rows[i].cells[tdindex].style.color=Td_Font_Color_Array[i][tdindex]; for(var c=0;c<Cell_Selected_Array.length;c++){ if(Cell_Selected_Array[c] == tdindex) Cell_Selected_Array.splice(c,1); } } } } //設置行的顏色 function Chang_Tr_over(me,Table_object,flag){ var trobject = me; while(trobject.tagName!="TR"){trobject = trobject.parentElement;} var trindex = trobject.rowIndex; var Table_Tr_Length = parseInt(Table_object.rows.length); var Table_Td_Length = parseInt(Table_object.rows[trindex].cells.length);
var flag_td =","+Cell_Selected_Array+","; for(var i=0;i<Table_Td_Length;i++){ var value = ","+i+","; if(flag_td.indexOf(value)!=-1) continue; if(flag==1){ Table_object.rows[trindex].cells[i].style.background=Tr_Change_BackGround; Table_object.rows[trindex].cells[i].style.color=Tr_Change_Fontcolor; }else{ Table_object.rows[trindex].cells[i].style.background=Td_BackGround_Color_Array[trindex][i]; Table_object.rows[trindex].cells[i].style.color=Td_Font_Color_Array[trindex][i]; } }