Autor Beitrag
Nighti
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 19

Win XP
D5 Standard
BeitragVerfasst: Do 24.06.04 18:52 
Hi,
wie kann ich im TWebBrowser bei einer HTML Seite eine Checkboxen "checken".
Also das sie angeklickt ist?

Geht das auch, wenn ich den Namen dieser nicht habe? Mit ner Item ID oder so?

Danke schon mal

Bye
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Do 24.06.04 19:57 
keine Ahnung ;-)
Aber vielleicht hilft dir der Code ?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
var
  Felement:IHTMLElementCollection;
  Len,lauf:Integer;
  Item: OleVariant;
  Item2: IHTMLElement;
...
    Felement:=WebEdit.DOM.all; // alle Elemente der DOM nehmen
   
    for i := 0 to Len - 1 do begin // jedes Element nehmen
      Item := FElement.Item(i, varEmpty);  // Element holen
      if (Item.TagName = 'P')or(Item.TagName = 'p') then begin // ist Element ein <p>
        Item2:=  FElement.Item(i, varEmpty) as IHtmlElement; // P-Element typecast
        Item2._AddRef; // warum auch immer
        Item2.removeAttribute('ID',0);  // alle ids wech
        item2.setAttribute('ID','neue_ID',0); // result = <P id=neue_UD>

..

grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
Nighti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 19

Win XP
D5 Standard
BeitragVerfasst: Do 24.06.04 20:06 
Hm nicht wirklich ^^
Vor allem ich bräucht das Attribut...
.Value geht nich... damit kann man ja Texte lesen / setzen
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Do 24.06.04 20:18 
na, ein bissle google, ein bissle msdn und dann kriegst auch ne Lösung; suchen musst aber schon :-)

msdn.microsoft.com/l...ce/objects/param.asp

Ein Input type=Checkbox hat das Attribut CHECKED in der DOM
einfach dass nehmen.

grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
Nighti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 19

Win XP
D5 Standard
BeitragVerfasst: Do 24.06.04 20:23 
Ja auf der Seite war ich auch auch schon *g*
die hat mir aber nicht wirklich weitergeholfen, weil dann die Fehlermeldung kommt, dass Checked nicht unterstützt wird

ausblenden Delphi-Quelltext
1:
webBrowser.OleObject.Document.Frames.Item(2).document.forms.item(0).elements.item('LottoZahl[]').Checked := true;					


so schaut das bei mir aus... aber das mag er ned ^^

( also das vorne dran müsste stimmen, da mir
ausblenden Delphi-Quelltext
1:
webBrowser.OleObject.Document.Frames.Item(2).document.forms.item(0).elements.item('button').Value;					

den Text des buttons "button" verrät.
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Do 24.06.04 20:29 
brrrrr, wat issn ditte ? :-) :-/
schau dir mal meinen Code an.
Greif direkt auf die DOM zu und nimm die bei MSDN angezeigten Eigenschaften. Die Übersetzung der Webbrowser-Type library hat nicht alle Eigenschaften und Kompos. ( :wink2: hallo Borlander), daher auch nur IHTMLElement. Das ist ungetypt (reines Interface) und der Compiler bringt keine Fehlermeldungen.

grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
Nighti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 19

Win XP
D5 Standard
BeitragVerfasst: Do 24.06.04 20:48 
wenn du das noch so formulieren könntest, dass selbst ein noob wie ich das versteht, wäre ich dir sehr dankbar :wink:
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Fr 25.06.04 17:35 
sodele,
also
versuch mal folgenden Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
    Felement:=WebEdit.DOM.all; // alle Elemente der DOM nehmen  
     
    for i := 0 to Len - 1 do begin // jedes Element nehmen  
      Item := FElement.Item(i, varEmpty);  // Element holen  
      if (Item.Name = 'Lottozahl') then begin // ist Element ein <p>  
        Item2:=  FElement.Item(i, varEmpty) as IHtmlElement; // P-Element typecast  
        Item2._AddRef; // warum auch immer  
        MyChecked:=Item2.Checked;  // alle ids wech


habs noch ncht verifiziert, sollte aber funzen
grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
ringo!
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48

WinXP Pro, MacOS X 10.3
D7 Pers
BeitragVerfasst: Mo 05.07.04 18:36 
Probier mal folgendes aus:

ausblenden Quelltext
1:
WebBrowser1.OleObject.Document.Forms.item(0).elements.item(6).Click;					


Ist mit ein wenig Spielerei verbunden. Anstelle der 6 einfach mal von 0 angefangen durchzuprobieren. Irgendwann triffst du die Checkbox ;) Hab leider nie rausbekommen, wie man die Nummer des Items direkt rausfindet.