各位大大,本人最近做一个报告页面。 
报告样式如Demo。后面有一栏是输入备注,输入完成后需要道出到Excel中保存。 
在但在页面中加入<input type='text' />后导出到Excel中也看到输入框非常的不美观。 
遂在导出前将输入框给替换掉。写下了一下的脚本。 
虽然能替换但是非常的不理想。示例中有4输入框只替换了两个。 
请帮我看看是哪里的问题?(代码如下,附件我也上传一份) 
先谢谢大家了。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml">   
<head>   
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   
<title>无标题文档</title>   
</head>   
<script language="javascript">   
   function testRep()   
   {   
    var iObj = document.getElementsByTagName("input");   
    var count = iObj.length;   
    var thisObj;   
    for(i=0;i<count;i++)   
    {   
        thisObj = iObj[i];    
        if(thisObj.type=="text")   
        {   
            //alert(thisObj.value);   
            thisObj.parentNode.innerText=thisObj.value;   
        }   
    }   
  }   
</script>   
<body>   
<table><tr><td>   
<input type="button" value="替换" onclick="testRep();" />   
</td>   
</tr></table>   
<table width="300" height="200" border="1" id="ReportTable">   
    <tr>   
        <td>1</td>   
        <td><input type="text" value="A"/></td>   
    </tr>   
    <tr>   
        <td>2</td>   
        <td><input type="text" value="B"/></td>   
    </tr>   
    <tr>   
        <td>3</td>   
        <td><input type="text" value="C"/></td>   
    </tr>   
    <tr>   
        <td>4</td>   
        <td><input type="text" value="D"/></td>   
    </tr>   
</table>   
</body>   
</html>  

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    <html xmlns="http://www.w3.org/1999/xhtml">   
    <head>   
    <meta http-equiv="Content-Type" content="text/html; charset=gbk" />   
    <title>无标题文档</title>   
    </head>   
    <script language="javascript">   
       function testRep()   
       {   
        var iObj = document.getElementsByTagName("input");   
        var count = iObj.length;   
        var thisObj;   
        for(i=0;i<count;i++)   
        {   
            thisObj = iObj[i];    
            if(thisObj.type=="text")   
            {   
                //alert(thisObj.value);   
                thisObj.parentNode.innerText=thisObj.value;
                i--;   
            }   
        }   
      }   
    </script>   
    <body>   
    <table><tr><td>   
    <input type="button" value="替换" onclick="testRep();" />   
    </td>   
    </tr></table>   
    <table width="300" height="200" border="1" id="ReportTable">   
        <tr>   
            <td>1</td>   
            <td><input type="text" value="A"/></td>   
        </tr>   
        <tr>   
            <td>2</td>   
            <td><input type="text" value="B"/></td>   
        </tr>   
        <tr>   
            <td>3</td>   
            <td><input type="text" value="C"/></td>   
        </tr>   
        <tr>   
            <td>4</td>   
            <td><input type="text" value="D"/></td>   
        </tr>   
    </table>   
    </body>   
    </html>  
      

  2.   

    感谢。调试成功了后来我将for语句修改也可以了
    for(i=count-1;i>=0;i--){
    ……
    }