Page.Option Method

The Option method generates an OPTION item in an HTML form selection list, and assigns it the value and selection state that you specify.

Syntax

Page.Option(Value, State)

Parameters

Value
The value of the option in the selection list.
State
A value that indicates whether the list option is the selected option. If State is equal to Value, then the HTML keyword SELECTED is inserted in the definition of the option list.

Example

The following example generates a selection field in an HTML form to enable the customer to select the expiration year of the credit card. The Option method generates <OPTION VALUE="> tags and marks the current year as selected:

iyear = Year(date) %>

<SELECT NAME="_cc_expyear">
    <% = mscsPage.Option(1997, iyear) %> 1997
    <% = mscsPage.Option(1998, iyear) %> 1998
    <% = mscsPage.Option(1999, iyear) %> 1999
    <% = mscsPage.Option(2000, iyear) %> 2000
    <% = mscsPage.Option(2001, iyear) %> 2001
    <% = mscsPage.Option(2002, iyear) %> 2002
    <% = mscsPage.Option(2003, iyear) %> 2003
</SELECT> 

Following is the HTML output that is produced by the ASP script shown previously, assuming that the current year is 1998:

<SELECT NAME="_cc_expyear">
    <OPTION VALUE="1997"> 1997
    <OPTION VALUE="1998" SELECTED> 1998
    <OPTION VALUE="1999"> 1999
    <OPTION VALUE="2000"> 2000
    <OPTION VALUE="2001"> 2001
    <OPTION VALUE="2002"> 2002
    <OPTION VALUE="2003"> 2003
</SELECT> 

Related Topics


© 1997-1998 Microsoft Corporation. All rights reserved.