Home > Language Reference > Web Functions > SelectHTMLItem

SelectHTMLItem

The SelectHTMLElement function selects the specified item in an HTML listbox or combobox.

Usage

Used to simulate an item selection in a listbox/combobox. If the listbox/combobox are not HTML elements, SelectHTMLElement is not able to select an item, but you can use the SendKeys function to send the first characters of the item and select it.

Syntax

ret=SelectHTMLItem(<html_descriptor>, <item> [, shift|ctrl])

Parameters

<html_descriptor>, string, HTML descriptor of the HTML listbox/combobox. In Recording mode, when you record a selection in such a list, the SelectHTMLItem statement is automatically generated.

<item>, string, text item.

shift|ctrl, optional keyword. If ctrl keyword is used, multiple SelectHTMLItem statements select item without unselecting the previous selection. If shift keyword is used, two SelectHTMLItem statements select all the items between the first and last items selected by the two statements.

Return value

ret, optional return code. If the function succeeds within the timeout (30 seconds by default or the #ActionTimeout value), the function returns 0. If the function fails, the return value is a nonzero value (see Web Functions Error Codes) BUT script execution is not stopped.

See also

SelectedHTMLItem$
ListHTMLItem$

Examples

'On the demonstration WinTask Web site, we click the Form link and then we fill the form:
StartBrowser("IE","www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ClickHTMLElement("A[INNERTEXT= 'Form']")
UsePage("Form")
    SelectHTMLItem("SELECT[NAME= 'subject']", "Web site")
    WriteHTML("INPUT TEXT[NAME= 'company']", "My Company")
    WriteHTML("INPUT TEXT[NAME= 'name']", "My Name")
    WriteHTML("INPUT TEXT[NAME= 'email']", "
test@test.com")
    ClickHTMLElement("INPUT CHECKBOX[NAME= 'contactsoon']")
    WriteHTML("TEXTAREA[NAME= 'message']", "Message")
    ClickHTMLElement("INPUT RESET[VALUE= 'Clear']")
CloseBrowser()


'On the demonstration WinTask Web site loaded in Firefox, we click the Form link and then we fill the form:
StartBrowser("FF","www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ClickHTMLElement("A[INNERTEXT= 'Form']")
UsePage("Form")
    SelectHTMLItem("SELECT[NAME= 'subject']", "Web site")
    WriteHTML("INPUT TEXT[NAME= 'company']", "My Company")
    WriteHTML("INPUT TEXT[NAME= 'name']", "My Name")
    WriteHTML("INPUT TEXT[NAME= 'email']", "test@test.com")
    ClickHTMLElement("INPUT CHECKBOX[NAME= 'contactsoon']")
    WriteHTML("TEXTAREA[NAME= 'message']", "Message")
    ClickHTMLElement("INPUT RESET[VALUE= 'Clear']")
CloseBrowser()