SelectedHTMLItem$
Web function.
The SelectedHTMLItem$ function returns the item selected in the specified combobox/listbox HTML element. Not available in WinTask Lite.
Usage
Used to retrieve what the user has selected in a combo or listbox in a web form for example.
Syntax
var$=SelectedHTMLItem$(<html_descriptor>)
Parameters
<html_descriptor>, unique identifier for the HTML combobox/listbox to retrieve the information from. Use Recording mode for generating automatically the html descriptor.
Return value
var$ returns what has been selected by the user in the specified html combobox/listbox. If the combo/listbox is not found within the web page specified by a previous UsePage, var$ is empty.
Remarks
See the second example below to ensure that the HTML combo/list is fully loaded before invoking SelectedHTMLItem$ function.
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()
'Same example using Firefox
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 WinTask Web site, synchronization tips : we suppose that all the pages have the same title WinTask,
and we want to retrieve what is per default in Subject fieldStartBrowser("IE", "www.wintask.com/demos")
UsePage("WinTask Demonstration Pages")
ClickHTMLElement("A[INNERTEXT= 'Same Title Pages']")
'If the new page has the same title as the previous one, the Recording mode does not generate a UsePage,
'so add it manually as below, execution of the UsePage line will finish only when all the HTML elements
'on the new web page are loaded.
UsePage("Page Title")WriteHTML("INPUT TEXT[NAME= 'company']", "Typing in first page")
ClickHTMLElement("A[INNERTEXT= 'here']")
'Write an additional UsePage line to force the synchro on the new page with the same titleUsePage("Page Title")
ClickHTMLElement("A[INNERTEXT= 'previous page']")CloseBrowser()