急!急!!急!!! 如下的页面的checkbox的名称是动态变化的,请问如何在WebBrowser中查找出该checkbox,并打勾确定 ( 积分: 100 )

L

leafv

Unregistered / Unconfirmed
GUEST, unregistred user!
各位大大,下面页面中如何找出checkbox,急哦,请各位大大一定教我,谢谢



<tr>
<td width=&quot;100%&quot; align=&quot;center&quot;>
<table width=&quot;98%&quot; border=&quot;0&quot; cellspacing=&quot;1&quot; cellpadding=&quot;2&quot; align=&quot;center&quot; class=&quot;table-style4&quot;>
<tr class=&quot;tr-ringlist&quot;>
<td height=&quot;30&quot; width=&quot;30&quot;>
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>订购<br/>标志</font></div>
</td>
<td height=&quot;30&quot; width=&quot;70&quot;>
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>物品代码</font></div>
</td>
<td height=&quot;30&quot;>
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>物品名称</font></div>
</td>
<td height=&quot;30&quot; >
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>供应商</font></div>
</td>
<td height=&quot;30&quot; width=&quot;40&quot;>
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>价格<br/>(元)</font></div>
</td>
<td height=&quot;30&quot; width=&quot;40&quot;>
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>订购<br/>次数</font></div>
</td>

</tr>

<tr bgcolor=&quot;E6ECFF&quot;>
<td align=&quot;center&quot;> <input type='checkbox' name='crbt150000001604' onclick='oncheckbox(this,&quot;150000001604&quot;,&quot;电视'> </td>
<td height=&quot;20&quot;>150000001604</td>
<td height=&quot;20&quot;>电视td>
<td height=&quot;20&quot;>苏州</td>
<td height=&quot;20&quot; align=&quot;center&quot;>
<div align=&quot;center&quot;>3000.00</div></td>
<td height=&quot;20&quot; align=&quot;center&quot;>
<div align=&quot;center&quot;>8424</div></td>


各位大大,页面中crbt150000001604 是随着物品代码变化而变化的。
这个值如果固定,可以用下面的方法找到
var
o: Olevariant;
begin

o := WebBrowser1.OleObject.document.all.item(‘crbt150000001604’,0);
o.click;
end;
这样做是ok的,
但是我把 crbt150000001604 写成动态就错了
我的写法如下
var
o: Olevariant;
crid;string;
begin
crid :='crbt150000001604'
o := WebBrowser1.OleObject.document.all.item(crid,0);
o.click;
end
这样写就报错了,请各位大大帮忙看看,给100分,解决另外送分
 
各位大大,下面页面中如何找出checkbox,急哦,请各位大大一定教我,谢谢



<tr>
<td width=&quot;100%&quot; align=&quot;center&quot;>
<table width=&quot;98%&quot; border=&quot;0&quot; cellspacing=&quot;1&quot; cellpadding=&quot;2&quot; align=&quot;center&quot; class=&quot;table-style4&quot;>
<tr class=&quot;tr-ringlist&quot;>
<td height=&quot;30&quot; width=&quot;30&quot;>
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>订购<br/>标志</font></div>
</td>
<td height=&quot;30&quot; width=&quot;70&quot;>
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>物品代码</font></div>
</td>
<td height=&quot;30&quot;>
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>物品名称</font></div>
</td>
<td height=&quot;30&quot; >
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>供应商</font></div>
</td>
<td height=&quot;30&quot; width=&quot;40&quot;>
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>价格<br/>(元)</font></div>
</td>
<td height=&quot;30&quot; width=&quot;40&quot;>
<div align=&quot;center&quot;><font color=&quot;#FFFFFF&quot;>订购<br/>次数</font></div>
</td>

</tr>

<tr bgcolor=&quot;E6ECFF&quot;>
<td align=&quot;center&quot;> <input type='checkbox' name='crbt150000001604' onclick='oncheckbox(this,&quot;150000001604&quot;,&quot;电视'> </td>
<td height=&quot;20&quot;>150000001604</td>
<td height=&quot;20&quot;>电视td>
<td height=&quot;20&quot;>苏州</td>
<td height=&quot;20&quot; align=&quot;center&quot;>
<div align=&quot;center&quot;>3000.00</div></td>
<td height=&quot;20&quot; align=&quot;center&quot;>
<div align=&quot;center&quot;>8424</div></td>


各位大大,页面中crbt150000001604 是随着物品代码变化而变化的。
这个值如果固定,可以用下面的方法找到
var
o: Olevariant;
begin

o := WebBrowser1.OleObject.document.all.item(‘crbt150000001604’,0);
o.click;
end;
这样做是ok的,
但是我把 crbt150000001604 写成动态就错了
我的写法如下
var
o: Olevariant;
crid;string;
begin
crid :='crbt150000001604'
o := WebBrowser1.OleObject.document.all.item(crid,0);
o.click;
end
这样写就报错了,请各位大大帮忙看看,给100分,解决另外送分
 
由于checkbox点击之后有oncheck事件
固下面这种方法不行
var

spDisp: IDispatch;
j: integer;

IDoc1: IHTMLDocument2;
iELC : IHTMLElementCollection ;
S2 : string;
HtmlInputEle : IHTMLInputElement;

begin
if webbrowser1<>nil then
begin
webbrowser1.Document.QueryInterface(IHTMLDocument2,iDoc1);
if iDoc1<>nil then
begin
ielc:=idoc1.Get_all;
for j:=0 to ielc.length-1 do
begin
Application.ProcessMessages;
spDisp := ielc.item(J, 0);
if SUCCEEDED(spDisp.QueryInterface(IHTMLInputElement ,HtmlInputEle))then
with HtmlInputEle do
begin
S2:=Type_;
S2:=UpperCase(S2);
//我把所有的input都填上 try , checkbox 都打勾
if StrComp(PChar(S2),'CHECKBOX')=0 then
begin
checked := True;
//click;
end;
end;


end; //END FOR //Details
end;
end;
 
顶部