Skip to main content

Displaying the Total Charge

Next, we want to display the total charge for the order, which is stored in the Total property of the TicketOrder class.

The value of Total is displayed in a text box, which is created with an <input> tag. To format the amount, we call the $FN (format number) function, requesting the default format with two decimal places.

Because the total value is for display purposes only—the user cannot change it—we have used the “readonly” attribute. (Unfortunately, Netscape browsers ignore this attribute, so the user may think he or she can change the value. If they do so, the value on the server is not affected.)

<html> <head></head>
<csp:class super="%CSP.Page,Cinema.Utils">
<csp:if condition='$D(%session.Data("Order"))'>
    <img src="YourTicketOrder.gif"><br>
    <script language="cache" runat="server">
        // Open Order object for display
        Set ord = ##class(Cinema.TicketOrder).%OpenId(%session.Data("Order"))
    <form name="OrderTickets">
    <csp:loop counter="num" from=1 to=#( ord.Items.Count() )#>
        <script language="cache" runat="server">
            Set itm = ord.Items.GetAt(num)
        showing of #(itm.Show.Film.Title)#
        at #(itm.Show.Theater.TheaterName)#
        <select name="AdultTickets">
        <select name="ChildTickets">
    Total Charge:
        size=5 readonly 
        value=#($FN(ord.Total, "", 2))#>
</body> </html>
FeedbackOpens in a new tab