Solved

Help Getting values from an HTML selectbox

Posted on 2004-04-08
6
206 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
Comment Utility
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
Comment Utility
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
Comment Utility
can you give me some more info about this library ?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 11

Expert Comment

by:shaneholmes
Comment Utility
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
Comment Utility
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
Comment Utility
Shane thanks, i've been busy a couple of days, i'll try it tonight and accept the answer.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now