Similar Question:
How to trigger the OnChange event of a "Select" element in Delphi WebBrowser?
Hey there,
I have a TWebBrowser in Delphi that loads a webpage containing a form with a dropdown menu. I am able to select an item from the dropdown, but the select element has an onchange event. How can I execute the onchange event in Delphi without using execScript('yourfunctioname()', 'JavaScript');
Here is the select element with the onchange event:
<select align="left" id="carrierNameDropDown_UNSHIPPEDITEMS" onChange="MYO.ES.OtherCarrierToggle (this, 'UNSHIPPEDITEMS' )">
<option value="0" selected="1" >Select</option>
<option value="Chronopost" >Chronopost</option>
<option value="City Link" >City Link</option>
<option value="DHL" >DHL</option>
<option value="DPD" >DPD</option>
<option value="Deutsche Post" >Deutsche Post</option>
<option value="Fastway" >Fastway</option>
<option value="FedEx" >FedEx</option>
<option value="GLS" >GLS</option>
<option value="GO!" >GO!</option>
<option value="Hermes Logistik Gruppe" >Hermes Logistik Gruppe</option>
<option value="La Poste" >La Poste</option>
<option value="Parcelforce" >Parcelforce</option>
<option value="Parcelnet" >Parcelnet</option>
<option value="Poste Italiane" >Poste Italiane</option>
<option value="Royal Mail" >Royal Mail</option>
<option value="SDA" >SDA</option>
<option value="Smartmail" >Smartmail</option>
<option value="TNT" >TNT</option>
<option value="Target" >Target</option>
<option value="UPS" >UPS</option>
<option value="Yodel" >Yodel</option>
<option value="Other">
Specify carrier:
</option>
</select>
I managed to achieve this by:
if EmbeddedWB1.Document <> nil then begin
if EmbeddedWB1.Document.QueryInterface(IHTMLDocument3,docb) = S_OK then begin
elb := docb.getElementById('carrierNameDropDown_UNSHIPPEDITEMS');
if elb <> nil then begin
(elb as IHTMLSelectElement).value := 'Parcelforce';
OleVariant (elb as IHTMLElement). FireEvent ('onchange');
end;