调查结果形成输入字段属于德尔福 [英] finding which form the input field belongs to delphi

查看:107
本文介绍了调查结果形成输入字段属于德尔福的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请按照我的$ P $,我设法回答自己pvious问题。我能够把文本输入字段在Delphi应用程序在web浏览器提供服务的网站上。有时也有在网站上的多种形式,大多数时间其左右2,但它可以上到一个放任几。现在的问题是。我如何'测试'或找出选定的输入字段所属形成。就让我们举一个例子。例如,gmail.com有2个输入字段:电子邮件和的passwd我也知道有这个网站2种形式。与code像这样的,你可以选择其中之一:

Follow my previous question which i managed to answer myself. I am able to place text in an input field on a website served on webbrowser in a delphi application. sometimes there are multiple forms on a website, most of the time its around 2, but it could head up to a faire few. Now my question is. How can I 'test' or find out which form the selected input field belongs. Lets just take an example. For example, gmail.com there are 2 input fields: 'Email' and 'Passwd' I also know that there are 2 forms on this site. with code like this one you can select either one of them :

doc:=webbrowser1.Document as IHTMLDocument2;
frm:=doc.forms.item(0,EmptyParam) as IHTMLFormElement;
fld:=frm.item('Email',EmptyParam) as IHTMLInputTextElement;
fld.value:=GetFieldValue(theForm,'test@gmail.com');

通过在第二线路改变0到1有网站上的第二种形式。现在我想知道我怎么可以让程序找出自身形成输入域所属了。你可以试试用做?还是别的什么?任何有什么想法?

by changing the 0 to a 1 in the second line you have the second form on the site. Now I want to know how can I let the program find out for itself which form the input field belongs too. could you do this with try? or anything else? Any have any idea?

推荐答案

fld.form 指向元素属于表格。您可以使用 doc.getElementFromId 或您想了解的元素,而无需使用的形式得到它,虽然这是最简单的,如果它有一个id任何其它方法。

fld.form points to the form the element belongs to. You can use doc.getElementFromId or any other method you like to get the element without using the form to get it, although it is easiest if it has an id.

另一种选择是通过各种形式进行搜索,以检查它是否有一个给定名称的字段,但如果一个字段在多于一个的形式存在,将不会帮你。

Other option is to search through all forms to check if it has a field with the given name, but that won't help you if a field exists in more than one form.

这篇关于调查结果形成输入字段属于德尔福的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆