后写的不能生效
加一句 theWrapDiv.innerHTML = theWrapDiv.innerHTML;就可以了

解决方案 »

  1.   

    以下是全部代码,IE6中确实可以运行,但根本没有效果,radio没有添加ID,label也没有添加for属性
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> 
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
    <title>车辆管理页面_弹出页面</title>

    <script type="text/javascript">
      //*-------为每个radio标签添加id,为每个label标签添加for属性-------
      window.onload = function(){
        var theWrapDiv = document.getElementById('carList');
            var theLabel = theWrapDiv.getElementsByTagName("label");
            var theInput = theWrapDiv.getElementsByTagName("input");
    document.title=12;
    for(i = 0; i < theInput.length; i ++){
       theInput[i].id = "state" + i;
            }
    for(j = 0; j < theLabel.length; j ++){
               theLabel[j].setAttribute("for","state" + j);
            }
      }
    </script>

    </head>
    <body>

      <!-- 车辆列表开始 -->
      <div id="carList">
        <ul>
      <li>
      <label>
            <input type="radio" >粤A32C51
      </label>
      </li>
      
      <li>
      <label>
            <input type="radio" >粤A32C52
      </label>
      </li>
      <li>
      <label>
            <input type="radio" >粤A32C53
      </label>
      </li>
    </ul>
      </div>

    </body>
    </html>
      

  2.   

    以下是全部代码,IE6中确实可以运行,但根本没有效果,radio没有添加ID,label也没有添加for属性
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> 
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
        <title>车辆管理页面_弹出页面</title>
         
        <script type="text/javascript">
          //*-------为每个radio标签添加id,为每个label标签添加for属性-------
          window.onload = function(){
            var theWrapDiv = document.getElementById('carList');
            var theLabel = theWrapDiv.getElementsByTagName("label");
            var theInput = theWrapDiv.getElementsByTagName("input");
            document.title=12;
            for(i = 0; i < theInput.length; i ++){
               theInput[i].id = "state" + i;
            }
            for(j = 0; j < theLabel.length; j ++){
               theLabel[j].setAttribute("for","state" + j);
            }
          }
        </script>
         
    </head>
    <body>
         
              <!-- 车辆列表开始 -->
              <div id="carList">
                <ul>
                  <li>
                      <label>
                        <input type="radio" name="radio1" >粤A32C51
                      </label>
                  </li>
                   
                  <li>
                      <label>
                        <input type="radio" name="radio1" >粤A32C52
                      </label>
                  </li>
                  <li>
                      <label>
                        <input type="radio" name="radio1" >粤A32C53
                      </label>
                  </li>
                </ul>
              </div>
         
    </body>
    </html>
      

  3.   

    应该是在添加 for 属性时,ie6/7 没有意识到要做和 id 关联的事情
    而通过 innerHTML 赋值时,赋值的内容是要做 html 解析的,所以 for 和 id 被关联起来了