function processZipData(){
if(xhr.readyState==4) {
var data=unescape(xhr.responseText);
var arrResult = data.split("###");
RemoveRow();
for(var i=0;i<arrResult.length;i++)
{

arrTmp = arrResult[i].split("@@@");
num1 = arrTmp[0]; //字段num1的值 lid
num2 = arrTmp[1]; //字段num2的值 uphone
num3 = arrTmp[2];    //msg
num4 = arrTmp[3];    //time

row1 = tb.insertRow();
if (i%2==0) {
row1.bgColor = '#FFFFFF';
}
else {
row1.bgColor = '#E7F1FA';
}

cell1 = row1.insertCell();
cell1.innerText = num1;
cell2 = row1.insertCell();
cell2.innerText = num2;
cell3 = row1.insertCell();
cell3.innerText = num3;
cell4 = row1.insertCell();
cell4.innerText = num4;
}
}
}
————————————————————————————————————
比如上面中,我要求cell1.innerText = num1;显示出来的文字头3个字是红色的,末尾3个字是绿色的,怎么实现? 小弟新新手,恳请赐教~ 3Q 。

解决方案 »

  1.   

    cell1.innerText = "<font color=red>" + num1.substring(0,3) + "</font>" + "<font color=green>" + num1.substring(3,3) + "</font>";
      

  2.   

    疏忽了一个地方,试一下这个:cell1.innerHTML = "<font color=red>" + num1.substring(0,3) + "</font>" + "<font color=green>" + num1.substring(3,3) + "</font>";innerHTML可以加HTML标记,而innertext只承认文本.
      

  3.   

    上面SUBSTRING也用错了最后修改一下,这个我试过了,好用cell2.innerHTML="<font color=red>" + num2.substring(0,3) + "</font>" + num2.substring(3,num2.length-3) + "<font color=green>" + num2.substring(num2.length-3) + "</font>";
      

  4.   

    谢谢
    显示正常了,可是IE提示"网页上有错误"
    错误:'num2'为空或不是对象
      

  5.   


    function processZipData(){
    if(xhr.readyState==4) {
    var data=unescape(xhr.responseText);
    之后加一句 alert(data); 自己去看,就知道传值的地方有问题了.
      

  6.   

    问题解决了,是我for循环多了一次。呵呵,谢谢 theforever(碧海情天) 的耐心指导。