Autor Beitrag
LittleBen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 258
Erhaltene Danke: 4

Win 7, Mac OS
Delphi 7
BeitragVerfasst: Mo 23.12.13 18:33 
Hallo,
ich versuche gerade eine Selectbox auszulesen, ohne den Webbrowser zu benutzen. Das Problem ist, dass die Selectbox beim Laden befüllt wird. Sie sieht folgendermaßen aus:
ausblenden HTML-Dokument
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
<body class="nav" onload="OnLoad(document.forms[0]);">
    <td align="left" class="tabelle">
      <span class="selection">
       <nobr>
        Element<br>
        <span class="absatz">
          <br>
        </span>
        <select name="element" class="selectbox">
    <option value="1">
?????.gif
    </option>
        </select>
       </nobr>
      </span>
     </td>
</body>


So hab ich versucht sie auszulesen
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
function TVPlanParser.GetSelectbox(aDoc: IHTMLDocument2): boolean;//; var Selectbox: IHTMLSelectElement): Boolean;
var
  Disp: IDispatch;
  SelEl: IHTMLSelectElement;
  i: Integer;
  OptionEl: IHTMLOptionElement;
  option_ids: array of WideString;
  option_texts: array of WideString;
begin
  // search the document for the SELECT element with the given name
  Disp:=(aDoc as IHTMLDocument2).all.item('element', EmptyParam);

  // EDIT: the following two lines are demonstrating how to get the element with focus
  // simulate user selection by setting focus to SELECT element
  (Disp as IHTMLElement2).focus;

  // basic error checking and acquiring of IHTMLSelectElement interface which is needed to access single OPTIONs within the SELECT
  if Assigned(Disp) and Supports(Disp, IHTMLSelectElement, SelEl) then
  begin
    // prepare array
    SetLength(option_ids, SelEl.length);
    SetLength(option_texts, SelEl.length);
    // get OPTIONs from SELECT
    for i:=0 to SelEl.length-1 do
    begin
      OptionEl := SelEl.Item(i,EmptyParam) as IHTMLOptionElement;
      // voila - read value and text of option element, store in arrays
      showmessage(OptionEl.Value);
      option_ids[i] := OptionEl.Value;
      option_texts[i] := OptionEl.Text;
    end;
  end;
end;
(stackoverflow.com/qu...rowser-into-an-array)
Damit bekomm ich aber nur den Wert "1", der von anfang an drin steht. Also wurde die OnLoad Funktion nicht aufgerufen :(
Hat jemand eine Ahnung wie ich an die andern Werte komm?

Viele Grüße
Littleben