Delphi Access drop-down menu in Web page

Source: Internet
Author: User

Delphi browses the Web page through Twebbrowser and then accesses the drop-down menu in the webpage:

Uses MsHtml;
procedureTform1.button1click (Sender:tobject);
var
Doc:ihtmldocument2;
Coll:ihtmlelementcollection;
IPos, Iindex:integer;
Selelem:ihtmlselectelement;
Optelem:ihtmloptionelement;
begin
Doc: = Webbrowser1.document as IHTMLDocument2;
If doc = nil then Exit;

COLL: = doc.all.tags (' select ') as IHTMLElementCollection;
IPos: = 0;The ordinal of the drop-down menu to access, starting with 0 for the first
Selelem: = Coll.item (IPos, 0) as ihtmlselectelement;
If Selelem = nil then Exit;

IIndex: = 2; //drop-down menu option number, starting from 0 for the first, 2 for the third option
Optelem: = Selelem.item (IIndex, 0) as IHTMLOptionElement;
If Optelem = nil then Exit;

ShowMessage (Optelem.text); //Gets the value of this option
optelem.selected: = True; //Select this option
end;

Delphi Access drop-down menu in Web page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.