whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

34 Visitors Online


 
...get access to RadioButtons in a TWebbrowser?
Autor:
[ Print tip ]  

Tip Rating (7):  
     


procedure TForm1.Button1Click(Sender: TObject);
var
  
Document: IHTMLDocument2;
  rbTestList: IHTMLElementCollection;
  rbTest: IHTMLOptionButtonElement;
  I: Integer;
begin
  
// Get a reference to the document
  // Referenz auf Dokument
  
Document := WebBrowser1.Document as IHTMLDocument2;

  // Get a reference to input-control (Radiobutton)
  // Referenz auf Eingabe-Control-Element (Radiobutton)
  
rbTestList := Document.all.item('rating', EmptyParam) as IHTMLElementCollection;

  // Get current values.
  // Aktuellen Wert auslesen
  
for I := 0 to rbTestList.Length - 1 do
  begin
    
// reference to the i. RadioButton
    // Referenz auf i. RadioButton
    
rbTest := rbTestList.item(I, EmptyParam) as IHTMLOptionButtonElement;

    // Show a message if radiobutton is checked
    // Anzeigen, wenn dieser RadioButton ausgewählt
    
if rbTest.Checked then
      
ShowMessageFmt('Der RadioButton mit dem Wert %s' +
        ' ist ausgewählt!', [rbTest.Value]);
  end;

  // Set new values
  // Neuen Wert setzen
  
for I := 0 to rbTestList.Length - 1 do
  begin
    
// reference to the i. RadioButton
    // Referenz auf i. RadioButton
    
rbTest := rbTestList.item(I, EmptyParam) as IHTMLOptionButtonElement;

    // check radiobutton with value 3.
    // Wir möchten den RadioButton mit dem Wert "3" aktivieren
    
if rbTest.Value = '3' then
      
rbTest.Checked := True;
  end;
end;

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners