473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Use JavaScript Classes to write a HTML table of Data.

Hi all,

I was wondering if anyone could help me display the HTML in a javascript that displays a table of data of prototype cinema listings.

This code brings up a Syntax error: Object doesn't support this property or method on line 99

Any ideas, folks?

Jonnie

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4. <h2>Booking Summary Sheet</h2>
  5.  
  6. <script language = "javascript" text = "text/javascript">
  7.  
  8. // CustomerBooking class
  9. function CustomerBooking(bookingId, customerName, film, showDate)
  10. {
  11.     this.bookingId = bookingId;
  12.     this.customerName = customerName;
  13.     this.film = film;
  14.     this.showDate = showDate;
  15. }
  16.  
  17. CustomerBooking.prototype.getBookingId = function()
  18. {
  19.     return this.bookingId;
  20. }
  21.  
  22. CustomerBooking.prototype.setBookingId = function(bookingId)
  23. {
  24.     this.bookingId = bookingId;
  25. }
  26.  
  27. CustomerBooking.prototype.getCustomerName = function()
  28. {
  29.     return this.customerName;
  30. }
  31.  
  32. CustomerBooking.prototype.setCustomerName = function(CustomerName)
  33. {
  34.     this.customerName = customerName; 
  35. }
  36.  
  37. CustomerBooking.prototype.getFilm = function()
  38. {
  39.     return this.film;
  40. }
  41.  
  42. CustomerBooking.prototype.setFilm = function(film)
  43. {
  44.     this.film = film;
  45. }
  46.  
  47. CustomerBooking.prototype.showDate = function()
  48. {
  49.     return this.showDate;
  50. }
  51.  
  52. CustomerBooking.prototype.showDate = function(showDate)
  53. {
  54.     this.showDate = showDate;
  55. }
  56.  
  57.  
  58. var firstBooking = new CustomerBooking(1234, "Robert Smith", "Raging Bull", "25 July 2004 18:20")
  59.  
  60. var secondBooking = new CustomerBooking(1244, "Arnold Palmer", "Toy Story", "27 July 2004 20:15")
  61.  
  62. document.write("First booking name is " + firstBooking.getCustomerName() + "<br>");
  63. document.write("Second booking name is " + secondBooking.getCustomerName());
  64.  
  65.  
  66. // cinema class
  67. function cinema()
  68. {
  69.     this.bookings = new Array();
  70. }
  71.  
  72. cinema.prototype.addBooking = function(bookingId, customerName, film, showDate)
  73. {
  74.     this.bookings[bookingId] = new CustomerBooking(bookingId, customerName, film, showDate);
  75. }
  76.  
  77. // booking HTML
  78. cinema.prototype.getBookingsTable = function()
  79. {
  80.    var booking;
  81.     var bookingsTableHTML  = "<table border = 1>";
  82.  
  83.    for (booking in this.bookings)
  84.       {
  85.     bookingsTableHTML += "<tr><td>";
  86.     bookingsTableHTML += this.bookings[booking].getBookingId();
  87.     bookingsTableHTML += "</td>";
  88.  
  89.     bookingsTableHTML += "<td>";
  90.     bookingsTableHTML += this.bookings[booking].getCustomerName();
  91.     bookingsTableHTML += "</td>";
  92.  
  93.     bookingsTableHTML += "<td>";
  94.     bookingsTableHTML += this.bookings[booking].getFilm();
  95.     bookingsTableHTML += "</td>";
  96.  
  97.     bookingsTableHTML += "<td>";
  98.     bookingsTableHTML += this.bookings[booking].getShowDate();
  99.     bookingsTableHTML += "</td>";
  100.     bookingsTableHTML += "</tr>";
  101.       }    
  102.       bookingsTableHTML += "</table>";
  103.     return bookingsTableHTML;    
  104. }
  105.  
  106.  
  107.     var londonOdeon = new cinema();
  108.  
  109.     londonOdeon.addBooking(342, "Arnold Palmer","Toy Story","15 July 2004 20:15");
  110.     londonOdeon.addBooking(335, "Louise Anderson","The Shawshank Redemption","27 July 2004 11:25");
  111.     londonOdeon.addBooking(566, "Catherine Hughes","Never Say Never","27 July 2004 17:55");
  112.     londonOdeon.addBooking(324, "Rob Gordon","Shrek","29 July 2004 20:15");    
  113.  
  114.     document.write(londonOdeon.getBookingsTable()); 
  115.  
  116. </script>
  117. </body>
  118. </html>
  119.  
Jun 14 '07 #1
2 1877
epots9
1,351 Expert 1GB
u have no getShowDate() function.

your calling getShowDate(), but u named the function showDate()

change the function name:
Expand|Select|Wrap|Line Numbers
  1. CustomerBooking.prototype.getShowDate = function(showDate)
  2.  
good luck
Jun 14 '07 #2
Thank you!!!!

In a rare stroke of intuition for me i figured what I did wrong.

I did indeed incorrectly set my get and set methods changing from this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. CustomerBooking.prototype.showDate = function()
  3. {
  4.     return this.showDate;
  5. }
  6.  
  7. CustomerBooking.prototype.showDate = function(showDate)
  8. {
  9.     this.showDate = showDate;
  10. }
  11.  
to this:

Expand|Select|Wrap|Line Numbers
  1. CustomerBooking.prototype.getShowDate = function()
  2. {
  3.     return this.showDate;
  4. }
  5.  
  6. CustomerBooking.prototype.setShowDate = function(showDate)
  7. {
  8.     this.showDate = showDate;
  9. }
  10.  
I couldn't see that until now.

Thanks :D
Jun 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: annoyingmouse2002 | last post by:
Hi there, sorry if this a long post but I'm really just starting out. I've been using MSXML to parse an OWL but would like to use a different solution. Basically it reads the OWL (Based on XML)...
2
by: Halldor Isak Gylfason | last post by:
I am faced with the task of porting a client application to a web architecture platform, e.g. to make it browser based. The technology I used was J2EE, e.g. servlets/JSP pages and HTML/javascript....
1
by: Jim, N2VX | last post by:
I'd like to create/display an Excel spreadsheet from javascript. We have an HTML page with results of a search and it can be reasonably large. The first attempt was to format the data into an...
2
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
5
by: googlegroups | last post by:
I have a large table in html created dynamically. This table can grow to several hundred rows or more. I have the ability to hide or display individual rows (using row.style.display = "none") and...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
7
by: e | last post by:
I've been having an extremely difficult time finding an answer to this in IE / js groups, so I thought I'd try here. I've got an aspx page that delivers loads of report data into custom-named...
4
by: bboyle18 | last post by:
Hi, I am working with a table sorting script which can be found here http://www.workingwith.me.uk/articles/scripting/standardista_table_sorting This script works very nicely, but when there is a...
3
by: anthonybrough | last post by:
I have an asp page that has a form to collect user data in a form. when the user clicks submit the input is validated. If any fields are not acceptable the user clicks on a button to go back to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.