<div>Sorry Jeremy,</div>
<div>&nbsp;</div>
<div>I have just come into the group after a while.</div>
<div>&nbsp;</div>
<div>If you are still on this project, one way to do this is as follows (Example dpr, pas and text version of form are below)</div>
<div>&nbsp;</div>
<div>The expected innerHTML on a SELECT tag object or other DOM functions don't always perform in MS for this kind of situation.</div>
<div>&nbsp;</div>
<div>The trick of it using MSHTML_TLB is to get ourselves an instance of IHTMLOptionElementFactory</div>
<div>&nbsp;</div>
<div>Here is the heart of it:</div>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<div>
<p>procedure TForm1.BitBtn3Click(Sender: TObject);<br>var<br>&nbsp;dropElement : IHTMLSelectElement;<br>&nbsp;optionElement : ihtmloptionelement;<br>&nbsp;window2 : IHTMLWindow2 ;<br>&nbsp;makeOPtion : IHTMLOptionElementFactory;<br>&nbsp;count : integer;
<br>begin</p>
<p>&nbsp; dropElement :=<br>&nbsp; (webbrowser1.document as ihtmldocument3).getElementById('ourDropDown') as IHTMLSelectElement;</p>
<p>&nbsp;</p>
<p>//first clear any existing OPTION tags&nbsp;&nbsp; (dropElement as ihtmlelement).innerHTML := '';</p>
<p><br>&nbsp;showmessage((dropElement as ihtmlelement).id + ' ok so far');<br><br>&nbsp; for count := low(displayText) to high(displayText) do<br>&nbsp;&nbsp; begin<br>&nbsp;&nbsp; window2 := (webbrowser1.Document as ihtmldocument2).parentWindow ;<br>
&nbsp;&nbsp;&nbsp;&nbsp; makeOPtion :=&nbsp;&nbsp; window2.Option;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; optionElement :=&nbsp; makeOPtion.create(displayText[count],valuesText[count],False,False);<br>&nbsp;&nbsp; dropElement.add(optionElement as ihtmlelement,True);<br>&nbsp;&nbsp; end;</p>
<p>end;</p></div></blockquote>
<div>&nbsp;</div>
<div>===================<br>program DropDown_Example;</div>
<div>
<p>uses<br>&nbsp; Forms,<br>&nbsp; main in 'main.pas' {Form1};</p>
<p>{$R *.res}</p>
<p>begin<br>&nbsp; Application.Initialize;<br>&nbsp; Application.CreateForm(TForm1, Form1);<br>&nbsp; Application.Run;<br>end.<br><br>=================</p></div>
<div>object Form1: TForm1<br>&nbsp; Left = 0<br>&nbsp; Top = 0<br>&nbsp; Width = 656<br>&nbsp; Height = 561<br>&nbsp; Caption = 'Form1'<br>&nbsp; Color = clBtnFace<br>&nbsp; Font.Charset = DEFAULT_CHARSET<br>&nbsp; Font.Color = clWindowText<br>&nbsp; Font.Height = -11
<br>&nbsp; Font.Name = 'Tahoma'<br>&nbsp; Font.Style = []<br>&nbsp; OldCreateOrder = False<br>&nbsp; OnCreate = FormCreate<br>&nbsp; PixelsPerInch = 96<br>&nbsp; TextHeight = 13<br>&nbsp; object Label1: TLabel<br>&nbsp;&nbsp;&nbsp; Left = 40<br>&nbsp;&nbsp;&nbsp; Top = 456<br>&nbsp;&nbsp;&nbsp; Width = 450
<br>&nbsp;&nbsp;&nbsp; Height = 13<br>&nbsp;&nbsp;&nbsp; Caption =<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Click &quot;Initialise&quot; try the drop down box, then Click &quot;Fill Drop ' +<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Down&quot; and try the drop down box.'<br>&nbsp; end<br>&nbsp; object WebBrowser1: TWebBrowser
<br>&nbsp;&nbsp;&nbsp; Left = 40<br>&nbsp;&nbsp;&nbsp; Top = 16<br>&nbsp;&nbsp;&nbsp; Width = 553<br>&nbsp;&nbsp;&nbsp; Height = 377<br>&nbsp;&nbsp;&nbsp; TabOrder = 0<br>&nbsp;&nbsp;&nbsp; ControlData = {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4C00000027390000F72600000000000000000000000000000000000000000000<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 000000004C000000000000000000000001000000E0D057007335CF11AE690800
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2B2E126208000000000000004C0000000114020000000000C000000000000046<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8000000000000000000000000000000000000000000000000000000000000000<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 00000000000000000100000000000000000000000000000000000000}<br>&nbsp; end
<br>&nbsp; object BitBtn1: TBitBtn<br>&nbsp;&nbsp;&nbsp; Left = 496<br>&nbsp;&nbsp;&nbsp; Top = 488<br>&nbsp;&nbsp;&nbsp; Width = 75<br>&nbsp;&nbsp;&nbsp; Height = 25<br>&nbsp;&nbsp;&nbsp; TabOrder = 1<br>&nbsp;&nbsp;&nbsp; Kind = bkClose<br>&nbsp; end<br>&nbsp; object BitBtn2: TBitBtn<br>&nbsp;&nbsp;&nbsp; Left = 40<br>&nbsp;&nbsp;&nbsp; Top = 408<br>&nbsp;&nbsp;&nbsp; Width = 81
<br>&nbsp;&nbsp;&nbsp; Height = 25<br>&nbsp;&nbsp;&nbsp; Caption = 'Initialise'<br>&nbsp;&nbsp;&nbsp; TabOrder = 2<br>&nbsp;&nbsp;&nbsp; OnClick = BitBtn2Click<br>&nbsp; end<br>&nbsp; object BitBtn3: TBitBtn<br>&nbsp;&nbsp;&nbsp; Left = 128<br>&nbsp;&nbsp;&nbsp; Top = 408<br>&nbsp;&nbsp;&nbsp; Width = 81<br>&nbsp;&nbsp;&nbsp; Height = 25<br>&nbsp;&nbsp;&nbsp; Caption = 'Fill Drop Down'
<br>&nbsp;&nbsp;&nbsp; TabOrder = 3<br>&nbsp;&nbsp;&nbsp; OnClick = BitBtn3Click<br>&nbsp; end<br>end</div>
<div>&nbsp;</div>
<div>==========</div>
<p>unit main;</p>
<p>interface</p>
<p>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls, Buttons, OleCtrls, SHDocVw, mshtml_tlb, activeX;</p>
<p>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp;&nbsp;&nbsp; WebBrowser1: TWebBrowser;<br>&nbsp;&nbsp;&nbsp; BitBtn1: TBitBtn;<br>&nbsp;&nbsp;&nbsp; BitBtn2: TBitBtn;<br>&nbsp;&nbsp;&nbsp; BitBtn3: TBitBtn;<br>&nbsp;&nbsp;&nbsp; Label1: TLabel;<br>&nbsp;&nbsp;&nbsp; procedure BitBtn3Click(Sender: TObject);<br>&nbsp;&nbsp;&nbsp; procedure FormCreate(Sender: TObject);
<br>&nbsp;&nbsp;&nbsp; procedure BitBtn2Click(Sender: TObject);<br>&nbsp; private<br>&nbsp;&nbsp;&nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp;&nbsp;&nbsp; { Public declarations }<br>&nbsp; end;</p>
<p>var<br>&nbsp; Form1: TForm1;<br>&nbsp;&nbsp; displayText : array [0 .. 2] of string = ('First', 'Second', 'Third');<br>&nbsp;&nbsp; valuesText : array [0 .. 2] of string = ('Chose Number One Option','Chose Number Two Option','Chose Number Three Option');
</p>
<p>&nbsp;&nbsp; implementation</p>
<p>{$R *.dfm}</p>
<p>procedure TForm1.BitBtn2Click(Sender: TObject);<br>&nbsp;// tip from Ron Loewy <a href="mailto:rloewy@hyperact.com">rloewy@hyperact.com</a><br>var<br>&nbsp; v: Variant;<br>&nbsp; HTMLDocument: IHTMLDocument2;<br>&nbsp; HTMLString : string;
<br>begin<br>&nbsp;&nbsp; HTMLString := '&lt;BODY&gt;'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +'&lt;Script&gt;function onChoose(drop){text = drop.options[drop.selectedIndex].value ;alert(text);}&lt;/script&gt;'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +'&lt;textarea style=&quot;position:absolute;top:10;left:300 &quot;&gt;Some text&lt;/textarea&gt;'
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +'&lt;select onclick=&quot;onChoose(this)&quot; id=&quot;ourDropDown&quot;&gt;&lt;option value=&quot;will disappear&quot;&gt;This will be replaced&lt;/option&gt;&lt;option value=&quot;will also disappear&quot;&gt;And So will this&lt;/option&gt;&lt;/select&gt;'
</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +'&lt;/BODY&gt;';<br>&nbsp; HTMLDocument := WebBrowser1.Document as IHTMLDocument2;<br>&nbsp; v := VarArrayCreate([0, 0], varVariant);<br>&nbsp; v[0] := HTMLString; // Here's your HTML string<br>&nbsp; HTMLDocument.Write
(PSafeArray(TVarData(v).VArray));<br>&nbsp; HTMLDocument.Close;<br>end;</p>
<p>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>webbrowser1.Navigate('about:blank');<br>end;</p>
<p>procedure TForm1.BitBtn3Click(Sender: TObject);<br>var<br>&nbsp;dropElement : IHTMLSelectElement;<br>&nbsp;optionElement : ihtmloptionelement;<br>&nbsp;window2 : IHTMLWindow2 ;<br>&nbsp;makeOPtion : IHTMLOptionElementFactory;<br>&nbsp;count : integer;
<br>begin</p>
<p>&nbsp; dropElement :=<br>&nbsp; (webbrowser1.document as ihtmldocument3).getElementById('ourDropDown') as IHTMLSelectElement;</p>
<p>&nbsp;&nbsp;&nbsp; (dropElement as ihtmlelement).innerHTML := '';<br>&nbsp;showmessage((dropElement as ihtmlelement).id + ' ok so far');<br>//rough and ready example here<br>&nbsp; for count := low(displayText) to high(displayText) do<br>&nbsp;&nbsp; begin
<br>&nbsp;&nbsp; window2 := (webbrowser1.Document as ihtmldocument2).parentWindow ;<br>&nbsp;&nbsp;&nbsp;&nbsp; makeOPtion :=&nbsp;&nbsp; window2.Option;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; optionElement :=&nbsp; makeOPtion.create(displayText[count],valuesText[count],False,False);<br>&nbsp;&nbsp; dropElement.add
(optionElement as ihtmlelement,True);<br>&nbsp;&nbsp; end;</p>
<p>end;</p>
<p>end.</p>
<div>=======</div>
<div>&nbsp;</div>
<div><br><br>&nbsp;</div>
<div><span class="gmail_quote">On 30/03/06, <b class="gmail_sendername">Jeremy Coulter</b> &lt;<a href="mailto:vss@vss.co.nz">vss@vss.co.nz</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div style="DIRECTION: ltr"><span class="e" id="q_10a4a34fb101f1d7_0">
<div dir="ltr" align="left"><br>&nbsp;</div>
<div></div>
<div><span><font face="Arial" size="2">Hi All.</font></span></div>
<div><span><font face="Arial" size="2">I am just looking into something, and have dropped a TWebBrowser onto a form.</font></span></div>
<div><span><font face="Arial" size="2">I thne download a test webpage and populate the Text of a text box, and checka&nbsp; checkbox, BUT I want to beable to add items to a Dropdown/combo box.</font></span></div>
<div><span><font face="Arial" size="2"></font></span>&nbsp;</div>
<div><span><font face="Arial" size="2">Anyone done this in the past?</font></span></div>
<div><span><font face="Arial" size="2"></font></span>&nbsp;</div>
<div><span><font face="Arial" size="2">Thanks, Jeremy</font></span></div><br>
<p><font size="2">--<br>No virus found in this outgoing message.<br>Checked by AVG Free Edition.<br>Version: 7.1.385 / Virus Database: 268.3.3/296 - Release Date: 29/03/2006<br></font></p><br>
<p><font size="2">--<br>No virus found in this outgoing message.<br>Checked by AVG Free Edition.<br>Version: 7.1.385 / Virus Database: 268.3.3/296 - Release Date: 29/03/2006<br></font></p></span></div><br>_______________________________________________
<br>Delphi mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://ns3.123.co.nz/mailman/listinfo/delphi" target="_blank">
http://ns3.123.co.nz/mailman/listinfo/delphi</a><br><br><br></blockquote></div><br>