Skip to main content

Calling the ChangeQuantity Method

The last step is to update the Orders page to call this method when an onChange event occurs. Three arguments are passed to the ChangeQuantity server-side method: the number of the TicketItem object; a 1 or 2, indicating adult or child tickets; and the newly-selected ticket quantity, which we get with the JavaScript code “this.selectedIndex”. In JavaScript, this identifies the current object, in this case the drop down list for which the onChange event occurred.

—Order.csp—
Order.csp
<html> <head></head>
<body>
    ...
    <csp:loop counter="num" from=1 to=#(ord.Items.Count() )#>
        <select name="AdultTickets"
        OnChange="#server(..ChangeQuantity( #(num)#, 1, this.selectedIndex) )#">
        ...
        </select>Adult Tickets<br>

        <select name="ChildTickets"
        OnChange="#server(..ChangeQuantity( #(num)#, 2, this.selectedIndex) )#">
        ...
        </select>Child Tickets<br>

    </csp:loop>
    ...
</body> </html>
Note:

To continue with the next part of this tutorial, click here.

FeedbackOpens in a new tab