Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LoIE.document...
Message
De
12/10/2009 07:21:01
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01428907
Message ID:
01428915
Vues:
49
>Hi
>
>Most of my websites I open automatically using the sintax below
>
>loIE.document.login.username.value = "acrisoft"
>loIE.document.login.password.value = password
>loIE.document.login.submit
>
>(where .login. is the form name)
>
>However I have an website which is php and seems it does not have a form name
>
>I would like to add my students automatically form my dbf file
>
>If anybody could help me at least to fill the username field...
Public oForm
oForm = Createobject('htmForm')
oForm.Show()

Define Class htmForm As Form
  Top = 0
  Left = 0
  Height = 450
  Width = 740
  DoCreate = .T.
  Caption = "HTML sample"
  Name = "Form1"
  cHTML = ""
  FirstTime = .T.

  * This is IE control - you'd use webbrowser4 from gallery instead
  * just because it already has some checks, extra pem. ie: wouldn't need readystate part
  * for the sake of keeping code short here I directly use olecontrol itself
  Add Object htmlviewer As OleControl With ;
    Height = 500, ;
    Width = 800, ;
    Anchor=15, ;
    OleClass = 'Shell.Explorer'

  Procedure Init
    Lparameters tcUrl
    With Thisform.htmlviewer
      .Navigate2('http://www.juntatecnica.com/cursos/login/signup.php?lang=en_utf8')
      Do While .ReadyState # 4 && Wait for ready state
      Enddo
      This.FillTheTextBoxes()
    Endwith
  Endproc

  Procedure FillTheTextBoxes()
    Local loDocument
    loDocument = Thisform.htmlviewer.Object.Document
    loDocument.All("id_username").Value = 'Cetin'
    loDocument.All("id_password").Value = 'xyz'
    loDocument.All("id_email").Value = 'xyz@nowhere.com'
    loDocument.All("id_email2").Value = '' && intentionally empty to cause error on submit
    loDocument.All("id_firstname").Value = 'Alex'
    loDocument.All("id_lastname").Value = 'De Souza'
    loDocument.All("id_city").Value = 'Istanbul'
    loDocument.All("id_country").Value = 'BR'


    Messagebox('',0,'',5000)
    loDocument.All("id_submitbutton").Click()

  Endproc

  Procedure htmlviewer.BeforeNavigate2
    Lparameters pdisp, url, Flags, targetframename, postdata, headers, Cancel
    Cancel = .T.
  Endproc

  Procedure htmlviewer.Refresh
    Nodefault
  Endproc
Enddefine
PS: If you are using google chrome then right click and select inspect element to walk the document model (others might have similar).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform