Home > Language Reference > Web Functions > SelectedHTMLItem$

SelectedHTMLItem$

The SelectedHTMLItem$ function retrieves the selected item from the specified HTML listbox or combobox.

Usage

Used to know and test the user selection in a listbox/combobox.

Syntax

var$=SelectedHTMLItem$(<html_descriptor>)

Parameters

<html_descriptor>, string, HTML descriptor of listbox/combobox. Use Spy tool for generating the html descriptor.

Return value

var$, string, return value which contains the user selection in the listbox or combobox. If the listbox/combobox element is not found in the current web page (defined by a previous UsePage), an empty string is returned.

Remarks

SelectedHTMLItem$ does not include any synchronization; a UsePage must be used before to be sure that the HTML element is ready.

See also

SelectHTMLItem
ListHTMLItem$ 

Examples

'On the demonstration WinTask Web site, we test what the user has selected in the Contact Us form:
StartBrowser("IE", "www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ClickHTMLElement("A[INNERTEXT= 'Form']")
UsePage("Form")
'The SelectHTMLItem waits for #ActionTimeout that the listbox is fully loaded.
SelectHTMLItem("SELECT[NAME= 'subject']", "Web site")
ClickHTMLElement("INPUT CHECKBOX[NAME= 'contactsoon']")
selection$=SelectedHTMLItem$("SELECT[NAME= 'subject']")
msgbox(selection$) 'Displays Web site
CloseBrowser()
 

'On the demonstration WinTask Web site loaded in Firefox, we test what the user has selected in the Contact Us form:
StartBrowser("FF", "www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ClickHTMLElement("A[INNERTEXT= 'Form']")
UsePage("Form")
'The SelectHTMLItem waits for #ActionTimeout that the listbox is fully loaded.
SelectHTMLItem("SELECT[NAME= 'subject']", "Web site")
ClickHTMLElement("INPUT CHECKBOX[NAME= 'contactsoon']")
selection$=SelectedHTMLItem$("SELECT[NAME= 'subject']")
msgbox(selection$) 'Displays Web site
CloseBrowser()


'On the demonstration WinTask Web site loaded in Chrome, we test what the user has selected in the Contact Us form:
StartBrowser("CH", "www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ClickHTMLElement("A[INNERTEXT= 'Form']")
UsePage("Form")
'The SelectHTMLItem waits for #ActionTimeout that the listbox is fully loaded.
SelectHTMLItem("SELECT[NAME= 'subject']", "Web site")
ClickHTMLElement("INPUT CHECKBOX[NAME= 'contactsoon']")
selection$=SelectedHTMLItem$("SELECT[NAME= 'subject']")
msgbox(selection$) 'Displays Web site
CloseBrowser()