js创建元素笔记


function showAreaData(weekId){

var currTR = event.srcElement.parentNode;

if(hasData==true && lastCell == weekId){

for(var s = 1 ; s <= n ; s ++){
currTR.parentNode.removeChild(currTR.nextSibling);
}
hasData = false;

}else{
if(hasData == true && lastCell != weekId){
for(var s = 1 ; s <= n ; s ++){
lastTR.parentNode.removeChild(lastTR.nextSibling);
}
hasData = false;
}
var productType = form.productType.value;
var businessType = form.businessType.value;
var serviceLevel = form.serviceLevel.value;
var customGroup = form.customGroup.value;
var areaId = form.areaNo.value;

//alert(areaId+" "+weekId+" "+productType+" "+businessType+" "+serviceLevel+" "+customGroup);

var xmlhttp = createXHR();
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4){
if(xmlhttp.status == 200){
var responseText = xmlhttp.responseText;

var trs = responseText.split("<tr>");

for(var i = 1 ; i < trs.length; i ++ ){
n = i;
var tr = trs[i].split("</tr>")[0];
//alert(tr);
var tds = tr.split('<td>');
//创建tr
var trNode = document.createElement("<tr id='TR_"+weekId+""+i+"' style='display:block;'></tr>");

for(var j = 1 ; j < tds.length; j ++){
var td = tds[j].split("</td>")[0];
//alert(td);
//创建td并添加到tr
var tdNode = document.createElement("<td align='right'></td>");
tdNode.innerHTML = td;
trNode.appendChild(tdNode);
}
//追加tr
currTR.parentNode.insertBefore(trNode,currTR.nextSibling);
}
}
}
}

var URL = "TotalAnalysisWeek.action?flag=getAreaData&weekId="+weekId+"&productType="+productType
+"&businessType="+businessType+"&serviceLevel="+serviceLevel+"&customGroup="+customGroup
+"&areaId="+areaId;

xmlhttp.open("post",URL,false);

xmlhttp.send(null);

hasData = true;
lastCell = weekId;
}
lastTR = currTR;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值