Solved

Help Getting values from an HTML selectbox

Posted on 2004-04-08
6
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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