0

我已经对此进行了几个小时的故障排除,但找不到任何我知道的语法错误。我无法让表格显示 AT。全部。我截断了声明 HTML 类型的代码的开头和作业中包含的注释。我只有几周的 JS 经验,在网站上发现了类似的问题,但找不到适用于我的问题。请帮我弄清楚为什么除了要显示的徽标和地址之外我无法获得任何东西!我对 HTML 不是很流利。(明天到期)

<script type="text/javascript" src="list.js"></script>

   <script type="text/javascript">
      var total = 0;
      function amountTotal(){
         var total = 0;
         for (var i = 0; i <= amount.length; i++){
            total = total + amount[i];
         }
         return total;
      }
   </script>

   <title>The Lighthouse</title>
   <link href="lhouse.css" rel="stylesheet" type="text/css" />

</head>

<body>

   <div id="title">
      <img src="logo.jpg" alt="The Lighthouse" />
      The Lighthouse<br />
      543 Oak Street<br />
      Owensboro, KY &nbsp;&nbsp;42302<br/>
      (270) 555-7511
   </div>

   <div id="data_list">
      <script type="text/javascript">
         document.write("<table border='1' rules='rows' cellspacing='0'>");
         document.write("<tr>");
         document.write("<th>Date</th><th>Amount</th><th>First Name</th><th>Last Name</th><th>Address</th>");
         document.write("</tr>");
            for (var i = 0; i < amount.length; i++) {
               If (i % == 0) {
                  document.write("<tr>");
               } else {
                  document.write("<tr class='yellowrow'>");
               }
               document.write("<td>"+ date[i] +"</td>");
               document.write("<td class='amt'>"+ amount[i] +"</td>");
               document.write("<td>"+ firstName[i] +"</td>");
               document.write("<td>"+ lastName[i] +"</td>");
               document.write("<td>"+ street[i] +"</ br>");
               document.write(city[i] + ", " + state[i] + " " + zip[i]);
               document.write("</td>");
               document.write("</tr>");
               document.write("</table>");
            }
      </script>

   </div>

   <div id="totals">

      <script type="text/javascript">
         document.write("<table border='1' cellspacing='1'>");
         document.write("<tr>");
         document.write("<th id='sumTitle' colspan='2'>Summary</th>");
         document.write("</tr>");
         document.write("<tr>");
         document.write("<th>Contributors</th>");
         document.write("<td>"+ amount.length +"</th>");
         document.write("</tr>");
         document.write("<tr>");
         document.write("<th>Amount</th>");
         document.write("<td>"+ amountTotal() +"</td>");
         document.write("</tr>");
         document.write("</table>");
   </div>

</body>
</html>
4

1 回答 1

0

你注意到这段代码了吗?

If (i % == 0) {
   document.write("<tr>");
} 

在第二个脚本块中。我认为应该是

if(i%something == 0)
{
    document.write("<tr>");
}
于 2013-11-12T02:28:54.843 回答