Search code examples
delphidelphi-7

Delphi 7 Webbrowser - select without value


I need help...My problem is:

Page source:

<select name="year" id="year" class="form-control select-inline">
<option>1990</option>
<option>1991</option>
<option>1992</option>
<option>1193</option>
</select>

In delphi 7, use:

WebBrowser1.OleObject.Document.All.Item('year', 0).value := '1990';

But form site continue in blank...Help me please


Solution

  • TWebBrowser is just a wrapper for the Internet Explorer ActiveX control, so this is really an IE DOM issue, not a Delphi issue.

    Try setting the select element's selectedIndex property instead of its value property:

    WebBrowser1.OleObject.Document.All.Item('year', 0).selectedIndex := 0;
    

    The value property is what gets transmitted to the server, but only of there is an item selected to begin with.