Java Reference
In-Depth Information
Let's call the getCustomerName() method of each of the two objects and write the results to the page.
document.write(“1st booking person's name is “ +
firstBooking.getCustomerName() + “<br />”);
document.write(“2nd booking person's name is “ +
secondBooking.getCustomerName());
And you'll see the following written into the page from information contained in these objects:
1st booking person's name is Robert Smith
2nd booking person's name is Arnold Palmer
Now let's put this together in a page.
<html>
<body>
<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;
}
Search WWH ::




Custom Search