Note that there are some explanatory texts on larger screens.

plurals
  1. POGetFormFieldNames not always working
    text
    copied!<p>I am trying to find out which form and element belongs too. The code that I now understand from this website:</p> <p><a href="http://www.cryer.co.uk/brian/delphi/twebbrowser/read_write_form_elements.htm" rel="nofollow">http://www.cryer.co.uk/brian/delphi/twebbrowser/read_write_form_elements.htm</a></p> <p>containing this code</p> <pre><code>function GetFormFieldNames(fromForm: IHTMLFormElement): TStringList; var index: integer; field: IHTMLElement; input: IHTMLInputElement; select: IHTMLSelectElement; text: IHTMLTextAreaElement; begin result := TStringList.Create; for index := 0 to fromForm.length do begin field := fromForm.Item(index,'') as IHTMLElement; if Assigned(field) then begin if field.tagName = 'INPUT' then begin // Input field. input := field as IHTMLInputElement; result.Add(input.name); end else if field.tagName = 'SELECT' then begin // Select field. select := field as IHTMLSelectElement; result.Add(select.name); end else if field.tagName = 'TEXTAREA' then begin // TextArea field. text := field as IHTMLTextAreaElement; result.Add(text.name); end; end; end; end; </code></pre> <p>seems to be working fine for most sites. However there are a few websites such as this one:</p> <p><a href="http://service.mail.com/registration.html#.1258-bluestripe-product1-undef" rel="nofollow">http://service.mail.com/registration.html#.1258-bluestripe-product1-undef</a></p> <p>By looking at that code and comparing it with the active id, I can find the form it is in. However it does not work for that website. for some reason I think it has to do with htmldocument3 adn that this code is for htmldocument2. But I am not sure. </p> <p>so my question is How can I extract a tstringlist from this website with all the elements names in them? hope you can help!</p> <p>Edited: Added some code</p> <pre><code> begin theForm := GetFormByNumber(webbrowser1.document as IHTMLDocument2, 0); fields := GetFormFieldNames(theForm); num := fields.IndexOf(theid); end; until (num &lt;&gt; -1); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload