Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to read a form field from a website

Posted on 2003-11-09
6
Medium Priority
?
213 Views
Last Modified: 2010-04-05
Dear all,

How can I read a form field value (MyField) from a website (http://www.mysite.com/mypage.htm)?
I'm using Delphi 7 with Indy.

Thanks, Abraham
0
Comment
Question by:abraham_ll
[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
6 Comments
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9737236
If you just load the source, it won't have a value. Please explain further or give a better example.
0
 

Author Comment

by:abraham_ll
ID: 9738036
Thank you for your reply EddieShipman.

This is a form field which displays the users IP number.  So on load it has a value. Here is the code:

<script language="javascript">
  var ip = '<!--#echo var="REMOTE_ADDR"-->'
  function ipval() {document.myform.ipaddr.value=ip;}
  window.onload=ipval
</script>
<form method="post" action="" name="myform">
  <input type="text" name="ipaddr" readonly>
</form>
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9738951
very easy. I will post a solution in a couple of hours.
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 500 total points
ID: 10499068
So sorry it has taken me so long to do this...

procedure TForm1.ParseURL(AURL: String);
Var
  IDoc:IHTMLDocument2;
  Strm:TSTringStream;
  v:Variant;
  i       : Integer;
  vMeta   : IHTMLMetaElement;
  vAll    : IHTMLElementCollection;
  vElement: IHTMLElement;
begin
  Memo1.Clear;
  Strm:=TSTringStream.create('');
  Idhttp1.Get(AURL,strm);
  Idoc:=CreateComObject(Class_HTMLDocument) as IHTMLDocument2;
  IDoc.designMode:='on';
  while IDoc.readyState<>'complete' do
    Application.ProcessMessages;
  v:=VarArrayCreate([0,0],VarVariant);
  v[0]:= Strm.datastring;
  IDoc.write(PSafeArray(System.TVarData(v).VArray));
  IDoc.designMode:='off';
  while IDoc.readyState<>'complete' do
    Application.ProcessMessages;

  vAll := iDoc.all.tags('INPUT');
  for i:=0 to vAll.Length-1 do
  begin
   vElement:= vAll.item(i, varEmpty);
 
   if (vElement.getAttribute('Name', 0) = 'ipaddr') then
   begin
     Result := vElement.getAttribute('Value', 0);
   end;
  end;
  IDoc := nil;
  Strm.Free;
end;
0

Featured Post

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!

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 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