急,出大事了,javascript的循环问题?
<style type="text/css">
body{
margin-top:5px;
}
table{
border:1px solid black;
border-collapse:collapse;
}
#td1{
border:1px solid black;
width:23px;height:23px;
text-align:center;
font-size:12px;
}
</style>
</head>
<body>
<table align="center">
<tr>
<script language="javascript">
for i=1 to 6
document.write "<td id='td1'>"&i&"</td>"
next
</script>
</tr>
</table>在ie中可以正常的显示1到6的格子,在火狐中怎么什么都没有显示啊?急急急,请指教啊?

解决方案 »

  1.   

    <html>
    <style type="text/css">
    body{
    margin-top:5px;
    }
    table{
    border:1px solid black;
    border-collapse:collapse;
    }
    #td1{
    border:1px solid black;
    width:23px;height:23px;
    text-align:center;
    font-size:12px;
    }
    </style>
    <script language="javascript">
    function a()
    {
    for(var i=1; i<=6;i++)
    {
    document.write("<td id='td1' style='border:1px solid '>"+i+"</td>");
    }
    }
    </script>
    </head>
    <body>
    <table align="center">
    <tr>
    <script>a();</script>
    </tr></table> 
    </html>看了你的代码 我真的寒心。
    现在 IE , FireFox 都可以显示6个格子了。 
      

  2.   

    for i=1 to 6 LZ以为JS是vb的语法啊
    JS是这样写的for(var i=1; i<=6;i++){
     //....
    }