SelectHTMLItem
Web function.
The SelectHTMLItem function selects an item in a Combobox/Listbox within a Web page.
Usage
Used to select an item from a listbox or a combobox displayed on a Web page. If the list/combo is a non-HTML plugin, SelectHTMLItem function will not recognize the list, and you can use Clipboard:
SendKeys("<Ctrl C">) to copy the text to Clipboard (use Down key if you need to select a different item than the one selected), and GetClipboard$ function to retrieve the content of Clipboard.
Syntax
ret=SelectHTMLItem(<html_descriptor>,item$[,shift|ctrl])
Parameters
<html_descriptor>, unique identifier for the HTML combobox/listbox where to select the item item$ within the current Web page specified by the last UsePage. See HTML descriptor for <html_descriptor> syntax. Use Recording mode for generating automatically the SelectHTMLElement syntax.
<item$>, string, text of the item to select.
shift or ctrl: if a multiple selection is done, the shift keyword is used for the last item selected, or the ctrl keyword is used for each individual item selected.
Return value
Ret, numeric return code. If the item has been successfully selected within 30 seconds (this default value can be changed using #ActionTimeout), the function returns 0 otherwise a return code is set but the execution does not stop whatever #IgnoreErrors value.
List of negative error codes
-1
No browser in use (no previous UsePage or StartBrowser)
-3
Bad descriptor, invalid syntax
-4
The browser has been lost (for instance because of a Closewindow)
-5
Page not found
-11
Specified item not found
-404,405
Usual http error codes (requires IE 6 or above)
Example
On WinTask Web site, we click the link Contact Us on the left menu:
StartBrowser("IE","www.wintask.com")
UsePage("WinTask - Automation software and Task Scheduler. Macro software with Macro Recorder")
ClickHTMLElement("A[INNERTEXT= 'Contact Us']")
UsePage("WinTask Contact Us")
SelectHTMLItem("SELECT[NAME= 'topic']", "Other . . .")
WriteHTML("INPUT TEXT[NAME= 'other']", "test")
WriteHTML("INPUT TEXT[NAME= 'name']", "test")
WriteHTML("INPUT TEXT[NAME= 'email']", "test@test.com")
ClickHTMLElement("INPUT CHECKBOX[NAME= 'contactsoon']")
ClickHTMLElement("INPUT SUBMIT[VALUE= 'Send']")
CloseWindow("IEXPLORE.EXE|IEFrame|WinTask - Thank you - Microsoft Internet Explorer",1)