procedure TForm1.Button4Click(Sender: TObject);
var
ovDoc, ovForms, ovForm, ovInput: OleVariant;
doc:ihtmldocument2;
input:ihtmlinputelement;//可以根据网页中文本框的情况定义多个
select:ihtmlselectelement;//同上,这个是针对复选框
submit:OleVariant;
I, J : Integer;
begin
if FDownComplete=false then Application.MessageBox('网页正在下载中,请稍后……', '提示', MB_OK + MB_ICONINFORMATION)
else begin
try
ovDoc := WebBrowser1.Document;
ovForms := ovDoc.all.tags('FORM');
for I := 0 to ovForms.length -1 do begin
ovForm := ovForms.item(I);
doc:=webbrowser1.Document as ihtmldocument2;
input:=doc.all.item('username',0) as ihtmlinputelement;
input.value:='风暴';//txt填写
input:=doc.all.item('email',0) as ihtmlinputelement;
input.value:='fengbao@123.com';//txt填写
input:=doc.all.item('phone',0) as ihtmlinputelement;
input.value:='12312312312';//txt填写
input:=doc.all.item('company',0) as ihtmlinputelement;//company selecte的name
input.value:='12312312312';//txt填写
select:=doc.all.item('sex',0) as ihtmlselectelement;
select.selectedindex:=2;//selecte填写 选择第二项
select:=doc.all.item('age',0) as ihtmlselectelement;
select.selectedindex:=2;//selecte填写 选择第二项
select:=doc.all.item('province',0) as ihtmlselectelement;
select.selectedindex:=2;//selecte填写 选择第二项
select:=doc.all.item('industry',0) as ihtmlselectelement;
select.selectedindex:=2;//selecte填写 选择第二项
select:=doc.all.item('headship',0) as ihtmlselectelement;
select.selectedindex:=2;//selecte填写 选择第二项
//submit:=doc.all.item(网页中提交按钮的名字,0);
ovForm.submit;
end;
except
FDownComplete := False;
end;
end;
自己写WebBrowser