Browser Control - How to submit :
original
* Create test htm
Text to m.Test noshow
EndText
StrToFile(m.test,'testme.htm')
oForm = Createobject('form1',Sys(5)+Curdir()+'testme.htm')
oForm.Show()
Read Events
Define Class form1 As Form
Top = 0
Left = 0
Height = 470
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 ;
Top = 12, ;
Left = 12, ;
Height = 396, ;
Width = 708, ;
Visible = .T., ;
Name = "HTMLViewer", ;
OleClass = 'Shell.Explorer'
Procedure Init
Lparameters tcHTML
With Thisform.htmlviewer
.Navigate2(m.tcHTML)
Do While .ReadyState # 4 && Wait for ready state
Enddo
Endwith
Endproc
Procedure htmlviewer.NavigateError
Lparameters pdisp, url, frame, statuscode, Cancel
Cancel = .T.
Endproc
Procedure htmlviewer.BeforeNavigate2
Lparameters pdisp, url, flags, targetframename, postdata, headers, Cancel
lcVals = ""
If This.Object.Document.Forms.Length > 0
For Each oFrm In This.Object.Document.Forms
lcVals = lcVals + oFrm.Name + Chr(13)
If oFrm.elements.Length > 0
For Each oElem In oFrm.elements
If oElem.Type = "select-multiple"
lcList=''
For ix=0 To oElem.Length-1
If oElem.Item(ix).Selected
lcList = lcList + Iif(Empty(lcList),'',',')+oElem.Item(ix).Value
Endif
Endfor
lcVals = lcVals + "Name :" + oElem.Name + "/Value:"+lcList + Chr(13)
Else
lcVals = lcVals + "Name :" + oElem.Name + "/Value:"+oElem.Value + Chr(13)
Endif
oElem = .Null.
Endfor
Endif
oFrm = .Null.
Endfor
Endif
Cancel = !thisform.FirstTime && prevents actual navigation
thisform.FirstTime = .F.
Messagebox(lcVals)
Endproc
Procedure htmlviewer.Refresh
Nodefault
Endproc
Procedure QueryUnload
Clear Events
Endproc
Enddefine