Posts: 50
Threads: 16
Joined: Oct 2004
I need to choose a selection from a combobox control on a web page. The format of the choices in the listbox are "dd-Mmm-yyyy hh:mm
s" but I only need the dd-Mmm-yyyy to match. (The time portion is arbitrary and unknown) Any help would be appreciated.
I may be misunderstanding this function "CB_SelectString" This is what I am using, but it keeps telling me "item not found"
act "Authorize.Net"
int hwnd=id(1 "Authorize.Net")
CB_SelectString hwnd "04-Apr-2005"
Thanks, Craig
Posts: 12,074
Threads: 141
Joined: Dec 2002
CB_ and other control functions are not used with controls in web pages. Use html element or accessible object functions.
Accessible object functions probably will not work here. Html element functions currently cannot select combobox items by text. Use this function:
Function Htm_CbSelect
function MSHTML.IHTMLElement&el VARIANT'item ;;Selects combobox item. item can be item index (0-based) or text (exact or with *).
if(!el) end ES_INIT
MSHTML.IHTMLSelectElement elsel=+el
int index
sel item.vt
,case VT_I4
,index=item
,if(index>=elsel.length) end "item not found"
,
,case VT_BSTR
,str s(item) ss c
,c.lpstr=wild_compile(s 1 0 0)
,MSHTML.IHTMLOptionElement elop
,index=-1
,foreach elop elsel
,,ss=elop.text
,,if(c) if(!wild_matchi(c ss ss.len)) continue
,,else if(ss~s=0) continue
,,index=elop.index; goto g1
,end "item not found"
,
,case else end ES_BADARG
;g1
if(index=elsel.selectedIndex) ret
elsel.selectedIndex=index
err+ end _error
#if (IEVER>=0x532)
MSHTML.IHTMLElement3 e=+elsel
e.FireEvent("onchange")
err+
#endif
Example
MSHTML.IHTMLElement el=htm("SELECT" "menu1" "" " Internet Explorer" 0 0 0x221)
Htm_CbSelect(el "04-Apr-2005*")