selectByText Method

             

Selects an item in a Listbox object based on its text.

Syntax

object.selectByText(strText)

Parameters

object

A Listbox script object.

strText

Specifies the text of the item you want to select.

Remarks

Use the selectByValue method to select an item based on the item's VALUE attribute.

Example

In the following example, the event handler adds items to an existing Listbox named Listbox1 and sets the default selection to "Cars" each time thisPage is first processed on the server.

function thisPage_onenter()
{
   ListBox1.addItem("Cars", 1);
   ListBox1.addItem("Planes", 2);
   ListBox1.addItem("Trains", 3);
   ListBox1.selectByText("Cars");
}