Skip to main content

Selecting a List Item

We also need to make sure that the current number of tickets is selected in the list. In HTML, we select a list item by specifying <option selected>.

It's easy to do this by using a <csp:if> tag to test whether the loop counter, i, is equal to the AdultTickets value from the object.

<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"))
    <csp:loop counter="num" from=1 to=#( ord.Items.Count() )#>
        <script language="cache" runat="server">
            Set itm = ord.Items.GetAt(num)
        For the #($ZT(itm.Show.StartTime,4))#
        showing of #(itm.Show.Film.Title)#
        at #(itm.Show.Theater.TheaterName)#
        <select name="AdultTickets">
            <csp:loop counter="i" from=0 to=9>
                <csp:if condition='itm.AdultTickets = i'>
                    <option selected>
        </select>Adult Tickets<br>
</body> </html>
FeedbackOpens in a new tab