-6

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

1 Answers1

1

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.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Dont work bro, i try value := 0; and :=1990 and two method continue blank. – Alex Silva May 18 '17 at 23:27
  • @AlexSilva as I said, DON'T set `value`, set `selectedIndex` instead. And clearly `1990` is not a valid index, your `select` only has indexes 0-3. – Remy Lebeau May 18 '17 at 23:28
  • Ahh ok bro, work now thx <3 – Alex Silva May 19 '17 at 00:23
  • One ask about WebBrowser, I have IE 11 in my computer, but IE show in WebBrowser is version 7, why? – Alex Silva May 21 '17 at 18:09
  • @AlexSilva because `TWebBrowser` runs in IE7 compatibility mode by default. See [How to have Delphi TWebbrowser component running in IE9 mode?](http://stackoverflow.com/questions/25843845/), and [TWebBrowser and FEATURE_BROWSER_EMULATION at runtime](http://stackoverflow.com/questions/6534614/), and other similar questions to enable other version modes. – Remy Lebeau May 21 '17 at 19:25