Solved

Help Getting values from an HTML selectbox

Posted on 2004-04-08
6
216 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
Independent Software Vendors: 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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