Solved

Help Getting values from an HTML selectbox

Posted on 2004-04-08
6
211 Views
Last Modified: 2010-04-04
Hello Experts!
I need a code to get the value from a HTML a html selectbox..

<option value=example1>example2</option>
i need the example1 value and example2 value
Can this be done by using WebBrowserComponent ?
Thanks in Advance!
0
Comment
Question by:bbh2k3
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10788949
You can drop a TWebBrowser on your form, you will then have to import the MS HTML control Type Library (Do you know how to do this?)

Use the code below to get to the document

procedure TForm1.Button1Click(Sender: TObject);
var
 Document: IHTMLDocument2;
begin
 WebBrowser1.Navigate('Your Url Here');
 Document:= WebBrowser1.Document as IHTMLDocument2;
end;

From here I can help you get to a particular Form Eleement - do ou know its name or ID?

Shane
0
 

Author Comment

by:bbh2k3
ID: 10788984
Shane:
<select name=tophone size=1 tabindex="3">
that's it. i'll now search for the MS HTML control type libs..
0
 

Author Comment

by:bbh2k3
ID: 10788997
can you give me some more info about this library ?
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 11

Expert Comment

by:shaneholmes
ID: 10789012
CLick component, import Active X

select from list

MS HTML Object Library

and click create unit

then add the unit to your uses clause

uses
  Windows ..........., MSHTML_TLB;


Shane
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 500 total points
ID: 10791367
bbh2k3, after some testing, I found that the MS HTML Object Type Library has
a interface (IHTMLSelectElement) which you can use to get to your dropdown box


procedure TForm1.Button1Click(Sender: TObject);
var
 aHTMLDoc : IHTMLDocument2;
 vControl : IHTMLSelectElement;
 S: String;
begin
if not VarIsEmpty(WebBrowser1.Document) then
 begin
   aHTMLDoc := WebBrowser1.Document as IHTMlDocument2;
   vControl:= aHTMLDoc.all.item('NameEdit', 0) as IHTMLSelectElement;
   {vControl.length; //number of items in dropdown}
   {vControl.selectedIndex //index of selected item}
   {vControl.item() //retrieve particular item}
 end;
end;

Shane
0
 

Author Comment

by:bbh2k3
ID: 10801011
Shane thanks, i've been busy a couple of days, i'll try it tonight and accept the answer.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question