一、包含引用单元mshtml,此单元中包含了必要的接口声明
二、示例代码如下
var
doc: IHTMLDocument2;
rbs: IHTMLElementCollection;
rb: IHTMLOptionButtonElement;
I: Integer;
begin
//取得对Document对像的引用,Document对像包含当前页面中的所有对像
doc := WebBrowser1.Document as IHTMLDocument2;
//取得指定单选按钮组的引用
rbs := doc.all.item('sex', EmptyParam) as IHTMLElementCollection;
//循环访问单选按钮组中的每个单选按钮
for I := 0 to rbs.Length - 1 do
begin
//注意,I是第一个参数,也就是把序号做为对像名称传递
rb := rbs.item(I, EmptyParam) as IHTMLOptionButtonElement;
//显示被选中的值
if rb.Checked then
ShowMessage('Checked Value:' + VarToStr(rb.value));
end;
end;
二、示例代码如下
var
doc: IHTMLDocument2;
rbs: IHTMLElementCollection;
rb: IHTMLOptionButtonElement;
I: Integer;
begin
//取得对Document对像的引用,Document对像包含当前页面中的所有对像
doc := WebBrowser1.Document as IHTMLDocument2;
//取得指定单选按钮组的引用
rbs := doc.all.item('sex', EmptyParam) as IHTMLElementCollection;
//循环访问单选按钮组中的每个单选按钮
for I := 0 to rbs.Length - 1 do
begin
//注意,I是第一个参数,也就是把序号做为对像名称传递
rb := rbs.item(I, EmptyParam) as IHTMLOptionButtonElement;
//显示被选中的值
if rb.Checked then
ShowMessage('Checked Value:' + VarToStr(rb.value));
end;
end;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/634491/viewspace-151169/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/634491/viewspace-151169/