Ich bin ein newB Lehre selbst JS mit JS ist Sexy, unter anderem. Ich kämpfe mit einer der Übungen und kann meinen Fehler nicht finden. Ich recherchierte und fand dieses Problem an einigen Stellen (einschließlich hier), aber keine von ihnen löste mein Problem. Ich bekomme nur meinen Titel und Fußzeile, wenn ich das führe.Ich brauche Hilfe, meinen Fehler mit diesem Code zu sehen
Ich werde meinen Code hier einfügen, um zu sehen, ob mir jemand helfen kann. Vielen Dank.
Ich hoffe, ich postete das richtig, weil es seltsam aussieht.
<!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>
Können Sie mehr technische Details zu Ihrem Problem angeben? Was ist das erwartete Verhalten Ihres Codes? Was hast du stattdessen bekommen? Was hast du probiert? – bigblind
@htoniv hat Ihren Rechtschreibfehler erwähnt, ich schlage vor, dass Sie in Zukunft eine Art von Linter verwenden (JSLint, ESLint, etc ..), und im strikten Modus können Sie diese Probleme leichter erkennen. Auch Sie können durch Ihren Code debuggen, der diesen Fehler leicht entdeckt haben sollte – MugiwaraUK