2016-07-10 17 views
-3

私は自分自身を教えていますJS JSを使用してJSはセクシーなものです。私は練習の一つで苦労しているし、私のエラーを見つけることができません。私はこの問題をいくつかの場所(ここを含む)で調査したが、問題を解決した人はいなかった。私はこれを実行するときに私のタイトルとフッタを取得します。私はこのコードで私のエラーを見る助けが必要です

私のコードをここに貼り付けて、誰かが私を助けることができるかどうか確認します。本当にありがとう。

私はそれが奇妙に見えるので、私はその権利を投稿したいと思います。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<html lang="en"> 
    <head> 
     <title>Chapter 5 Example 8</title> 
    </head> 

    <body> 

    <h2>Summary of Bookings</h2> 

    <script type="text/javascript"> 

//CustomerBooking type 

    function CustomerBooking(bookingId, customerName, film, showDate) 
    { 
     this.customerName = customerName; 
     this.bookingId = bookingId; 
     this.showDate = showDate; 
     this.film = film; 
    } 

    CustomerBooking.prototype.getCustomerName = function() 
    { 
     return this.customerName; 
    } 

    CustomerBooking.prototype.setCustomerName = function(customerName) 
    { 
     this.customerName = customerName; 
    } 

    CustomerBooking.prototype.getShowDate = function() 
    { 
     return this.showDate; 
    } 
    CustomerBooking.prototype.setShowDate = function(showDate) 
    { 
     this.showDate = showDate; 
    } 
    CustomerBooking.prototype.getFilm = function() 
    { 
     return this.film; 
    } 
    CustomerBooking.prototype.setFilm = function(film) 
    { 
     this.film = film; 
    } 
    CustomerBooking.prototype.getBookingId = function() 
    { 
     return this.bookingId; 
    } 
    CustomerBooking.prototype.setBookingId = function(bookingId) 
    { 
     this.bookingId = bookingId; 
     } 

    //Cinema type 

    function Cinema() 
    { 
     this.bookings = new Array(); 
    } 

    Cinema.prototype.addBooking = function(bookingId, customerName, film, showDate) 
    { 
     this.bookings[bookingId] = new CustomerBooking(bookingId, customerName, film, showDate); 
    } 

    Cinema.prototype.getBookingsTable = function() 
    { 
     var booking; 
     var bookingTableHTML = "<table border=1>"; 

     for (booking in this.bookings) 
     { 
      bookingsTableHTML += "<tr><td>"; 
      bookingsTableHTML += this.bookings[booking].getBookingId(); 
      bookingsTableHTML += "</td>)" 

      bookingsTableHTML += "<td>"; 
      bookingsTableHTML += this.bookings[booking].getCustomerName(); 
      bookingsTableHTML += "</td>;" 

      bookingsTableHTML += "<td>";    
      bookingsTableHTML += this.bookings[booking].getFilm(); 
      bookingsTableHTML += "</td>"; 

      bookingsTableHTML += "<td>"; 
      bookingsTableHTML += this.bookings[booking].getShowDate(); 
      bookingsTableHTML += "</td>"; 
      bookingsTableHTLM += "</tr>"; 
     } 

     bookingsTableHTML += "</table>"; 
     return bookingsTableHTML; 
    } 

    var londonOdeon = new Cinema(); 
    londonOdeon.addBooking(342, "Arnold Palmer", "Toy Story", "15 July 2009 20:15"); 
    londonOdeon.addBooking(335, "Louise Anderson", "The Shawshank Redemption", "27 July 2009 11:25"); 
    londonOdeon.addBooking(566, "Catherine Hughes", "Never Say Never", "27 July 2009 19:55"); 
    londonOdeon.addBooking(324, "Beci Smith", "Shrek", "29 Jluly 2009 20:15"); 

    document.write(londonOdeon.getBookingsTable()); 

</script> 


    </body> 
</html> 
+0

問題の技術的詳細を教えてもらえますか?あなたのコードの予想される動作は何ですか?代わりに何を得ましたか?何を試しましたか? – bigblind

+0

@htonivはあなたのスペルミスを教えてくれました。あなたはLinterを将来(JSLint、ESLintなど)使用することをお勧めします。strictモードでは、これらの問題をより簡単に見つけることができます。 また、このミスを簡単に発見したはずのコードを使ってデバッグすることができます – MugiwaraUK

答えて

0

あなたの変数は、このvar bookingTableHTML = "<table border=1>";ようなものですが、あなたの代わりに間違いがbookingTableHTMLですが、あなたはbookingsTableHTMLを使用しているbookingTableHTML += "<tr><td>";

を使うbookingsTableHTML += "<tr><td>";に割り当てています。

+0

大丈夫、Bigblind、MugiwaraUK、&htnivに感謝します。私は他のすべてを変更するのではなく、bookingsTableHTMLに変更することにしました。 JSLintとの大きな戦いをしていました(あまりユーザーフレンドリーではありません)。私は今、上映会で私のテーブルを見ることができます。 – MayChild

関連する問題