リスト項目の選択
また、現在のチケットの枚数が、リストから選択された枚数と一致しているかを確認する必要もあります。HTML では、<option selected> の指定によってリスト項目を選択します。
ループ・カウンタ i が、オブジェクトからの AdultTickets 値と同じであるかどうかをテストする <csp:if> タグを使用すると、簡単に確認することができます。
—Order.csp—
Order.csp
<html> <head></head>
<body>
<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"))
</script>
<csp:loop counter="num" from=1 to=#( ord.Items.Count() )#>
<script language="cache" runat="server">
Set itm = ord.Items.GetAt(num)
</script>
For the #($ZT(itm.Show.StartTime,4))#
showing of #(itm.Show.Film.Title)#
at #(itm.Show.Theater.TheaterName)#
<br><br>
<select name="AdultTickets">
<csp:loop counter="i" from=0 to=9>
<csp:if condition='itm.AdultTickets = i'>
<option selected>
<csp:else>
<option>
</csp:if>
#(i)#
</option>
</csp:loop>
</select>Adult Tickets<br>
</csp:loop>
</csp:if>
</body> </html>