Single-choice Select tags are functionally directly equivalent to a group of Radio buttons. There's one difference: a Select tag has its options defined as a set of option tags. In EWD, you should define those option tags within the page's pre-page script. Let's imagine we want an HTML form in our EWD page that contains a Select tag that displays a set of cities. In your EWD page you would simply have the following:
City: <select name="city"></select>
Note that you don't define any option tags and no logic is included in the EWD page to define how an option is pre-highlighted when the page loads. All this logic is placed in the page's pre-page script.
To define the option tags, you use the appendToList API method, for example:
d clearList^%zewdAPI("city",sessid) d appendToList^%zewdAPI("city","London","lon",sessid) d appendToList^%zewdAPI("city","New York","nyc",sessid) d appendToList^%zewdAPI("city","Sydney","syd",sessid) d appendToList^%zewdAPI("city","Paris","par",sessid)
Note the clearList call which clears out any existing options for the city drop-down. Also note that the order in which you call the appendToList method determines the order in which the options are displayed in the drop-down list.
To pre-highlight an option when the page is displayed, in the page's pre-page script, set the corresponding EWD Session variable to the value you want checked, mapping via the field's name, eg
In this case the option Sydney will be highlighted when the page is displayed. Of course, typically you'll determine the value to highlight based on information retrieved from the database.
When the form is submitted, the associated Action Script simply gets the value from the matching EWD Session variable, eg:
Click the Enterprise Web Developer/Examples tab for worked examples.