And for those of you who need a cool function to fillout forms using
TWebBrowser - here it is:

I trust this saves you all a load of time!

function FillForm(WebBrowser: TWebBrowser; FieldName: string; Value:
string): Boolean;
var
  i, j: Integer;
  FormItem: Variant;
begin
  Result := False;
  //no form on document
  if WebBrowser.OleObject.Document.all.tags('FORM').Length = 0 then
  begin
    Exit;
  end;
  //count forms on document
  for I := 0 to WebBrowser.OleObject.Document.forms.Length - 1 do
  begin
    FormItem := WebBrowser.OleObject.Document.forms.Item(I);
    for j := 0 to FormItem.Length - 1 do
    begin
      try
        //when the fieldname is found, try to fill out
        if FormItem.Item(j).Name = FieldName then
        begin
          FormItem.Item(j).Value := Value;
          Result := True;
        end;
      except
        Exit;
      end;
    end;
  end;
end;


On Mon, Aug 16, 2010 at 10:38 AM, Andre van Zuydam <an...@spiceware.co.za>wrote:

> Hi There
>
> I would start looking at the OleObject variable,  I use the code below to
> go through the elements of the form.  I will need to look a little further
> if this is not what you need.  Iterating through the elements is probably
> the best way to get data out of the page.
>
> var
>   ovElements: OleVariant;
>
> begin
>   ovElements := WebBrowser.OleObject.Document.forms.item(0).elements;
> end
>
>
>
> On Mon, Aug 16, 2010 at 4:53 AM, -K2RFP- <rn...@verizon.net> wrote:
>
>> I'm using a TWebBrowser component to open and display
>> a webpage that is simple text.
>> How can I gain access to the web page contents so I
>> can save it to a file by clicking a button on my
>> application?
>>
>> __________________________________________________
>> Delphi-Talk mailing list -> Delphi-Talk@elists.org
>> http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk
>>
>
>
>
> --
> Andre van Zuydam
> Spiceware Software
> =============================
> Email:  an...@spiceware.co.za
> Tel:    +27 83 391 8443
> Fax:   +27 86 682 6944
> Web:    www.spiceware.co.za
> =============================
>



-- 
Andre van Zuydam
Spiceware Software
=============================
Email:  an...@spiceware.co.za
Tel:    +27 83 391 8443
Fax:   +27 86 682 6944
Web:    www.spiceware.co.za
=============================
__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk

Reply via email to