TEmbededWB click a button

I have used the fill form to populate the text box now I need to click the button fo post it. I found FillFormAndExcecute  but not working for me.
250 points because I need to figure out whats going on tonight.


begin
 WB.Navigate('http://www.autocheck.com/?utm_medium=partner&utm_campaign=partner&utm_source=DMV.org&WT.mc_id=2401&siteID=2401&vin=');
  WB.Wait;
  with WB do
  begin
    FillForm('vin', 'KNDJA7231V5547306'); 
  end;

Open in new window

Grant FullenAsked:
Who is Participating?
 
smotConnect With a Mentor Commented:

uses
 MSHTML_EWB;
 
procedure TForm1.FormCreate(Sender: TObject);
begin
 WB.Navigate('http://www.autocheck.com/?utm_medium=partner&utm_campaign=partner&utm_source=DMV.org&WT.mc_id=2401&siteID=2401&vin=');
end;
 
function WB_ClickButton(WebBrowser: TEmbeddedWB; FieldName: string;
  FieldType: string='submit'): Boolean;
var
  iDoc1: IHTMLDocument2;
  Index: Integer;
  Disp: IDispatch;
  Inp: IHTMLInputElement;
begin
  WebBrowser.Document.QueryInterface(IHTMLDocument2, iDoc1);
  Result := iDoc1 <> nil;
  if Result then
  begin
    for Index := 0 to IDoc1.all.length - 1 do
    begin
      Disp := IDoc1.all.item(Index, 0);
      if (Supports(Disp, IHTMLInputElement, Inp))
        and (SameText(Inp.type_, FieldType) and SameText(Inp.Value, FieldName)) then
      begin
        (Inp as IHTMLElement).click;
        Result := True;
        Exit;
      end;
    end;
  end;
end;
procedure TForm1.WBDocumentComplete(ASender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
  WB.FillForm('vin', 'KNDJA7231V5547306');
  WB_ClickButton(WB, 'Go');
end;

Open in new window

0
 
Grant FullenAuthor Commented:
I found the code below here but it does not work properly.
procedure TForm1.wbDocumentComplete(ASender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var
  AdminSubmit : IHTMLInputElement;
  MyDocument : IHTMLDocument3;
begin
   MyDocument := wb.Document as IHTMLDocument3;
   if Assigned(MyDocument) then
   begin
   AdminSubmit := (MyDocument.getElementsByName('vin').item(0,'')as
IHTMLInputElement);
     if Assigned(AdminSubmit) then  AdminSubmit.Form.Submit;
   AdminSubmit.Form.Submit;
end;

Open in new window

0
 
Grant FullenAuthor Commented:
WOW thanks for writing the function :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.