html数据转换成表格,JSON数据转换成table表格

string path =request.getcontextpath();

string basepath = request.getscheme()+"://"+request.getservername()+":"+request.getserverport()+path+"/";

%>

.table-result{

width:100%;

border:1px solid #f2f2f2;

text-align:left;

border-collapse: collapse;

}

.table-result th{

height:40px;

font-weight: normal;

font-size:14px;

line-height:22px;

text-align:center;

background-color:#f0f0f0;

border-right:2px solid #fff;

color:#4e4e4e;

border-style: solid;

border-width: 1px;

border-color: gray;

}

.table-result td{

text-align:center;

height:40px;

font-size:12px;

line-height:22px;

color:#4e4e4e;

border-style: solid;

border-width: 1px;

border-color: gray;

padding-left: 2px;

padding-right:2px;

}

td

{

white-space:nowrap;

}

原始记录

${logquerydatamodel.origrec }

最新记录

${logquerydatamodel.lastrec}

$(document).ready(function(){

$("textarea").each(function(i){

var p = $(this).text();

if($.trim(p)=="") $(this).replacewith("");

if(p!="\n\t\n\t"){

var json;

try{

json = json.parse(p);

var id="";

if($(this).attr("id")!= null)

id="id="+$(this).attr("id");

var t1="

var flag=0;

var tr1="

";

for(var j in json)

{

if(flag>0)

{

t1+="

";

}

for(var item in json[j])

{

if(flag==0)

{

if(item!="")

t1+="

"+item+"";

tr1+="

"+json[j][item]+"";

}else

{

t1+="

"+json[j][item]+"";

}

}

if(flag==0)

t1+="

"+tr1+"";

else

t1+="";

flag++;

}

$(this).replacewith(t1);

}catch(e)

{

}

}

});

var flag = 0;

$("textarea").each(function(i){

$(this).prev().remove();

$(this).remove();

flag+=1;

});

if(flag==2)

{

$("form").html("

(此操作无详细数据)

");

}

if(flag==1)

{

var ts = $("table[id$=rec]");

for(var i=0;i

{

for(var c=0;c

{

var a = ts[i].rows[1].cells[c].innertext;

var b = ts[i+1].rows[1].cells[c].innertext;

if(a!=b)

{

ts[i].rows[1].cells[c].style.backgroundcolor='gray';

ts[i].rows[1].cells[c].style.color='white';

ts[i+1].rows[1].cells[c].style.backgroundcolor='gray';

ts[i+1].rows[1].cells[c].style.color='white';

}else if(a==""&&b=="")

{

ts[i].rows[0].cells[c].style.display='none';

ts[i+1].rows[0].cells[c].style.display='none';

ts[i].rows[1].cells[c].style.display='none';

ts[i+1].rows[1].cells[c].style.display='none';

}

}

}

}

});

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值