html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
无标题页张三 | 李四 | 王五 | |
数学 | 55 | 66 | 77 |
68 | 71 | ||
英语 | 99 | ||
语文 | 33 | 44 | 55 |
//=============================
//页面画线
//table 为空单元格画斜线
//输入框,span 为空,上加横线
//autor:dy
//lastDate:20080522
//============================
String.prototype.trim = function()
{
return this.replace(/(^/s*)|(/s*$)/g, "");
}
//table内画线
//一般表格斜线
function LookForTb(table,divID){
for (var i=0; i
{
for (var j=0; j
{
var obj = table.rows[i].cells[j];
var x,y,x1,y1;
var o = findLastRow(obj,table);
//alert('obj.innerText='+obj.innerText+'obj.innerText.trim()='+obj.innerText.trim())
if( tdIsNull(obj))
{
o=findLastRow(obj,table);
//记录初始位置
x=obj.offsetLeft;
y=obj.offsetTop;
//记录结束位置
x1=o.offsetLeft+o.offsetWidth;
y1=o.offsetTop+o.offsetHeight;
//跳过已画线单元格
if(o.cellIndex>obj.cellIndex)
{
j=o.cellIndex;
}
//跳过已画线行
if(o.parentNode.rowIndex>obj.parentNode.rowIndex)
{
i=o.parentNode.rowIndex;
}
}
//画线
varstr="";
// alert(str);
var o=document.createElement(str);
divID.innerHTML += o.outerHTML;
}
}
}
//递归找到最后一个空列
function LookFortr(obj,table)
{
var o=obj;
var i=obj.parentNode.rowIndex;
var j=obj.cellIndex;
//alert(i+":"+j);
j++;
if(table.rows[i].cells[j] != null && table.rows[i].cells[j] != "undefined" )
{
if( tdIsNull(table.rows[i].cells[j]))
{
o=table.rows[i].cells[j];
o=LookFortr(o,table);
}
}
return o;
}
//找到最后一个空行
function findLastRow(obj,table)
{
var o=LookFortr(obj,table);
//判断当前行是否空行
if(IsEmptyRow(o,table))
{
r=table.rows[o.parentNode.rowIndex+1];
if(r==null || r=='undefined')
{
return o;
}
o=table.rows[o.parentNode.rowIndex+1].cells[0];
if(o!=null && o!='undefined')
{
//判断下一行是否空行
if(IsEmptyRow(o,table)) //下一行如果空行
{
//alert('bb');
o=findLastRow(o,table);
}
else //返回当前行最后列
{
//alert('aa');
o=LookFortr(obj,table);
}
}
}
return o;
}
//是否空行
function IsEmptyRow(obj,table)
{
var tmp="";
var tmpHTML="";
i=obj.parentNode.rowIndex;
for(j=0;j
{
if(table.rows[i].cells[j].tagName!="INPUT" && table.rows[i].cells[j].tagName != 'IMG' && table.rows[i].cells[j].tagName!="input" && table.rows[i].cells[j].tagName != 'img')
{
//alert('table.rows[i].cells[j].innerHTML='+table.rows[i].cells[j].innerHTML+'table.rows[i].cells[j].innerText='+table.rows[i].cells[j].innerText);
//alert(table.rows[i].cells[j].innerText);
try{
tmp+=table.rows[i].cells[j].innerText.trim().replace(" ","").replace(" ","");
tmpHTML+=table.rows[i].cells[j].innerHTML;
}
catch(e)
{
//alert(e.message);
}
}
else
{
return tdIsNull(table.rows[i].cells[j]);
}
}
//alert("tmp="+tmp+"!!!!!!!!!!!!!!!!!!");
//alert(tmpHTML);
if(tmp=="")
{
//alert('true');
return true;
}
else
{
//alert('false');
return false;
}
}
//判断单元格内控件值是否为空
function tdIsNull(o)
{
if(o.getElementsByTagName("img").length>0)
{
//alert(o.innerHTML);
return false;
}
if(o.getElementsByTagName("input").length>0)
{
var v="";
for(var i=0;i
{
if(o.all.item(i).tagName=="INPUT")
{
v+=o.all.item(i).value;
}
}
if(v.trim()=="")
{
return true;
}
else
{
return false;
}
}
else if(o.innerText.trim()=="")
{return true;}
return false;
}