Solved

Help Getting values from an HTML selectbox

Posted on 2004-04-08
6
209 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

22 Experts available now in Live!

Get 1:1 Help Now