Delphi Coding - Filling the Form on the Website

Delphi Coding - Filling the Form on the Website

TWebBrowser with Delphi programming, create a customized web browsing internet explorer for your applications, file and network scanning, document viewing etc. Gives skills. You can also add functionality to add data to your web browser with your applications.


A form on a website's page allows the page visitor to enter data sent to the server to process.

The simplest web form consists of a text or a textbox, and a submit button (submit).

Most web search engines (eg Google) use such a web form to allow you to search the Internet.

More complex forms include drop-down lists, checkboxes, radio buttons, and so on. includes. A web form is like a standard window format that includes text input and selection controls.

Each form contains a push button that tells a button to process the web in the web form.


With any desktop application you can control web forms through the program. In our example, we will display any web page with a form entry using TWebBrowser, and we'll show you how to fill out and submit the corresponding fields of the form on the page.


Please note that the example below can be seen as a login login only, but by expanding the fields to be filled in by going through these codes, contact form, membership etc. can apply for all forms such as.


Let's begin the construction of our program

First, we create the form of our application with the delphide File - New - VCL Form Application. Then add 2 Edit and 1 Button to our form. Let's not forget to add mshtml to the Uses section.

Let's add a TWebBrowser control called bir WebBrowser1 ser to make it easier to track transactions. And in the Form1.Oncreate event, let's set this TWebBrowser's Navigate to the page that contains the member login, contact, membership, etc. form of the relevant website. If you set TWebBrowser's Silent to gör True, TW you will not see any unnerving errors that the site will cause when opening.


There's a point you shouldn't miss. You need to see the source code of the website form page that you have added and get the name of the form name and the boxes to be filled. As you can see in the example in the source code of the page;


form = "form" name = "frmLogin1" id = "frmLogin1" method = "post" action = "">
input type = "text" class = "form-control" id = "txtMemberNumber1" name = "txtMemberNumber">
/ Div>
div class = "form-group">
label for = "txtPassword1"> Password
input type = "password" class = "form-control" id = "txtPassword1" name = "txtPassword">
/ Div>

Form Name: frmLogin1

Member Number Box Name: txtMemberNumber1

Name of Password Box: txtPassword1

 Then add the following code to the Button1.Click event.

procedure TForm1.Button1Click (Sender: TObject);
there is
doc: IHTMLDocument2;
frm: ıhtmlformelement;
fld: ıhtmlınputtextelement;
doc: = WebBrowser1.Document as IHTMLDocument2;
frm: = doc.forms.item ('frmLogin1', EmptyParam) as IHTMLFormElement;
fld: = frm.item ('txtMemberNumber1', EmptyParam) as IHTMLInputTextElement;
fld.valu A = edit1.text;
fld: = frm.item ('txtPassword1', EmptyParam) as IHTMLInputTextElement;
fld.valu A = edit2.text;

In the Form1.Create event; (You must enter the relevant site address where the form is located.)

procedure TForm1.FormCreate (Sender: TObject);
WebBrowser1.Navigate A ( 'http: //');

NOTE: You must add mshtml to the uses section to compile the methods listed here.

All of these programs and the information you enter in the User Name and Password boxes will be filled in the form information center of the relevant site when you click the button and the information will be sent on the site.

Your comments will give us better directions. Do not spare your comments.

Im Sincerely Bir to discuss your next topic

You can download the running instance of the program from the link below.

Click to download the program's Delphi Source Codes