February 12, 2009

WinTask - SelectHTMLItemByValue (undocumented function)

'
' SelectHTMLItemByValue - selects an item in a Combobox/Listbox within a Web page.
'      This undocumented function is like SelectHTMLItem(), except
'      that it selects by value rather than item text.
'
' Author: Joe Strazzere
'
'
' ret=SelectHTMLItemByValue(<html_descriptor>,item$[,shift|ctrl])
'

' go to http://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml_option
'
' Paste in the following, and click "Edit and Click Me >>":
'  &lt;html&gt;
'  &lt;body&gt;
'  &lt;select name="MySelect" size=4 multiple="multiple"&gt;
'    &lt;option value="a"&gt;Volvo&lt;/option&gt;
'    &lt;option value="b"&gt;Saab&lt;/option&gt;
'    &lt;option value="c"&gt;Mercedes&lt;/option&gt;
'    &lt;option value="d"&gt;Audi&lt;/option&gt;
'  &lt;/select&gt;
'  &lt;/body&gt;
'  &lt;/html&gt;

'
' Then run this script
'

UsePage("Tryit Editor v1.4")
    SelectHTMLItemByValue("SELECT[NAME= 'MySelect']", "a")
    SelectHTMLItemByValue("SELECT[NAME= 'MySelect']", "b", shift)
    SelectHTMLItemByValue("SELECT[NAME= 'MySelect']", "d", ctrl)