Article View: borland.public.cppbuilder.internet.web
Article #796IHTMLSelectElement put_onchange syntax
From: Mitch McInelly
Date: Tue, 31 Jan 2006 17:40
Date: Tue, 31 Jan 2006 17:40
79 lines
3992 bytes
3992 bytes
Can someone please show me how I can fire an onchange event for a dropdown
list after I select one of the items programatically? My current code is:
TComInterface<IHTMLDocument2> Doc;
ActiveBrowser->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&Doc);
if( Doc )
{
TComInterface<IHTMLElementCollection> All;
Doc->get_all(&All);
if( All )
{
long count = 0;
All->get_length(&count);
for(long idx = 0; idx < count; ++idx)
{
TVariant item = idx;
TVariant index = 0;
TComInterface<IDispatch> Disp;
All->item(item, index, &Disp);
if( Disp )
{
WideString value;
int found;
TComInterface<IHTMLSelectElement> Input;
Disp->QueryInterface(IID_IHTMLSelectElement,(LPVOID*)&Input);
Value = "";
if( Input ) // Found a Drop down box
{ IDispatch *ppvdispOption;
IHTMLOptionElement *ppvOption;
BSTR *pszOptText;
WideString name;
Input->get_name(&name);
AnsiString Name = AnsiString(name);
if(UpperCase(Name)==UpperCase(AnsiString(Field)))
{
long i;
long length;
Input->get_length(&length);
for(i=0;i<length;i++)
{TVariant index = i;
Input->item( index, index, &ppvdispOption );
ppvdispOption->QueryInterface(
IID_IHTMLOptionElement,(void **)
&ppvOption);
ppvOption->get_text(&value);
AnsiString TValue = AnsiString(value);
Trim(TValue);
if(UpperCase(TValue)==UpperCase(Value))
{
Input->put_selectedIndex(i); // Selects
correct item from list
if(Special=='C') // Control needs to fire
onchange event...
{
TComInterface<IHTMLSelectElement> Input;
Disp->QueryInterface(IID_IHTMLSelectElement,(LPVOID*)&Input);
Input->put_onchange(index);
(etc)
This code does not appear to fire the onchange event. I know it's because
of the TVariant that I am passing to the event but I don't know what it's
looking for,
Thanks for looking
Mitch McInelly
Technical Details
Message-ID:
<43dfa1e5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: feeec,4307e96a2fc07463,start X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Mitch McInelly" <mitch@agencysoftware.com> From: "Mitch McInelly" <mitch@agencysoftware.com> Newsgroups: borland.public.cppbuilder.internet.web Subject: IHTMLSelectElement put_onchange syntax Date: Tue, 31 Jan 2006 09:40:00 -0800 Lines: 82 Organization: Agency Software, Inc. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 207.88.115.45 Message-ID: <43dfa1e5$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1138729445 207.88.115.45 (31 Jan 2006 09:44:05 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail