Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
listbox entry
#1
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:mmConfuseds" 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
#2
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
Code:
Copy      Help
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
Code:
Copy      Help
MSHTML.IHTMLElement el=htm("SELECT" "menu1" "" " Internet Explorer" 0 0 0x221)
Htm_CbSelect(el "04-Apr-2005*")


Forum Jump:


Users browsing this thread: 1 Guest(s)