Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using HTML code in Visual Fox Pro
Message
From
17/09/2005 11:18:27
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
17/09/2005 10:03:23
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01050590
Message ID:
01050602
Views:
38
>I am seeking for examples and resources on how to write\implement HMTL code into my foxpro applicatons. Your help would be greatly appreicated.
>
>
>Thank You In Advance
>
>
>
>Winfred Majors

You mean an HTML driven form? ie:
Public oForm
oForm = Createobject('form1', GetHTML())
oForm.Show()

Function GetHTML
  Local myVar
TEXT to myVar noshow
<html>
<head>
<title>New User Sign Up</title>
<script language="JScript">
function LoadTreeView()
{
	var TreeView1 = document.all('Treeview1');
    var oNode = TreeView1.Nodes.Add(null,0,"top","My Tree");
    TreeView1.Nodes.Add("top",4,"root0","Main node 0");
    TreeView1.Nodes.Add("top",4,"root1","Main node 1");
    TreeView1.Nodes.Add("top",4,"root2","Main node 2");
    TreeView1.Nodes.Add("root1",4,"child11","Child11");
    TreeView1.Nodes.Add("root1",4,"child12","Child12");
    TreeView1.Nodes.Add("root2",4,"child21","Child21");
    TreeView1.Nodes.Add("child11",4,"child111","child111");
    TreeView1.Nodes.Add("child11",4,"child113","child113");
    TreeView1.Nodes.Add("child113",3,"child112","child112");
    oNode.Expanded = true;
}
function CheckTable(dbcPath,dbfName)
{
  var strCn = "Provider=VFPOLEDB;Data Source=" + dbcPath;
  var strSQL = "select * from " + dbfName;

  var oConn = new ActiveXObject("Adodb.Connection");
  oConn.ConnectionString = strCn;
  oConn.Open;
  var oRS = oConn.Execute(strSQL);

  var lst="<TABLE border='1'><TR>";
  var Maxfields=5;
  var MaxRows=20;

  for (i=0;i<Math.min(oRS.Fields.Count,Maxfields);i++)
  {
    lst += "<TH>";
    lst += oRS.Fields(i).Name;
    lst += "</TH>";
  }
  lst += "</TR>";

  var counter=0;
  while (!oRS.eof && counter < MaxRows)
  {
    lst += "<TR>";
    for (i=0;i<Math.min(oRS.Fields.Count,Maxfields);i++)
    {
      lst += "<TD>";
      lst += oRS.Fields(i).Value;
      lst += "</TD>";
    }
    lst += "</TR>";
    oRS.MoveNext();
    counter++;
  }
  lst += "</TABLE>";
  oConn.Close();
  tablelist.innerHTML = lst;
  return true;
}
</script>
</head>
<body bgcolor=Turquoise onload="LoadTreeView();">
<h1 align="Center"><font color="#000080">New User Sign Up</font></h1>
<form method="GET" action="empty.htm" target="_self" name="myForm">
    <table border="0" cellspacing="1">
      <tr><td>ID</td><td><input type="text" name="ID" size="16" maxlength="16"></td></tr>
      <tr><td>First Name</td><td><input type="text" name="First" size="30" maxlength="15"></td></tr>
      <tr><td>Last Name</td><td><input type="text" name="Last" size="30" maxlength="20"></td></tr>
   <td>Gender?</td>
   <td>
     <select name="Selection1">
       <option value="0">- Gender -</option>
       <option value="1">Female</option>
       <option value="2">Male</option>
     </select></td></tr>
<tr>
   <td>Multi Selection</td>
   <td>
     <select multiple name="MulSelection">
       <option value="0">- Sports you watch -</option>
       <option value="1">Basketball</option>
       <option value="2">Soccer</option>
       <option value="3">Football</option>
       <option value="4">Volleyball</option>
       <option value="5">Formula1</option>
       <option value="6">Nascar</option>
     </select></td></tr>
	</table>
<TEXTAREA ID=txtComments STYLE="overflow:scroll; width:70%; height:150">
Sometimes an HTML based VFP form can be cool.
Think you could have syntax coloring on a form :)
Play flash movie (better play "Need For Speed" - post me too if you find a flash version), have a calendar etc.
</TEXTAREA>
  <p>
<input type=submit name=sub1 value="Write" onclick='document.all("submitter").value="writeButton";'>
<input type=submit name=sub2 value="Update" onclick='document.all("submitter").value="updateButton";'>
<input type=submit name=sub3 value="Clear" onclick='document.all("submitter").value="clearButton";'>

<p>
<object name="Treeview" classid="clsid:C74190B6-8589-11D1-B16A-00C0F0283628" 
  id="TreeView1" width="242" height="159">
  <param name="_ExtentX" value="6403">
  <param name="_ExtentY" value="4207">
  <param name="_Version" value="393217">
  <param name="HideSelection" value="1">
  <param name="Indentation" value="1000">
  <param name="LabelEdit" value="0">
  <param name="LineStyle" value="0">
  <param name="PathSeparator" value="/">
  <param name="Sorted" value="0">
  <param name="Style" value="7">
  <param name="Checkboxes" value="0">
  <param name="FullRowSelect" value="0">
  <param name="HotTracking" value="0">
  <param name="Scroll" value="1">
  <param name="SingleSel" value="0">
  <param name="ImageList" value>
  <param name="BorderStyle" value="0">
  <param name="Appearance" value="1">
  <param name="MousePointer" value="0">
  <param name="Enabled" value="1">
  <param name="OLEDragMode" value="0">
  <param name="OLEDropMode" value="0">
</object>
</p>
</form>
<input type=hidden name="submitter" value=0>
<p>Browse a VFP table</p>
<table>
<TR><TD>Locate DBC</TD><TD><input type='file' size='80' name='DBCLOCATION'></TD></TR>
<TR><TD>TableName</TD><TD><input type='text' size='80' name='TABLENAME'></TD></TR>
</TABLE><HR>
<input type='button' value='List' onClick="CheckTable(DBCLOCATION.value,TABLENAME.value);return;">
<div id='tablelist'></div>
</body>
</html>
ENDTEXT
  Return myVar

Define Class form1 As Form
  Top = 0
  Left = 0
  Height = 500
  Width = 800
  DoCreate = .T.
  Caption = "HTML sample"
  Name = "Form1"
  cHTML = ""
  cHTMFile = Forcepath(Sys(2015)+'.htm',Sys(2023))
  EmptyHTM = Forcepath('empty.htm',Sys(2023))
  DoNotErase = .F.

  Add Object htmlviewer As OleControl With ;
    Top = 12, ;
    Left = 12, ;
    Height = 450, ;
    Width = 700, ;
    Visible = .T., ;
    Name = "HTMLViewer", ;
    OleClass = 'Shell.Explorer'

  Procedure Destroy
    If !This.DoNotErase
      Erase (This.cHTMFile)
    Endif
  Endproc

  Procedure Init
    Lparameters tcHTML, tlIsFile
    Do Case
      Case Empty(m.tcHTML)
        Strtofile('<HTML><BODY></BODY></HTML>',This.cHTMFile)
      Case m.tlIsFile
        This.cHTMFile = m.tcHTML
        This.DoNotErase = .T.
      Otherwise
        Strtofile(m.tcHTML,This.cHTMFile)
    Endcase
    Strtofile('<HTML>&lt;% Response.Redirect "nowhere" %><BODY></BODY></HTML>',This.EmptyHTM)

    With Thisform.htmlviewer
      .Navigate2('file://'+This.cHTMFile)
      Do While .ReadyState # 4 && Wait for ready state
      Enddo
    Endwith
  Endproc

  Procedure htmlviewer.BeforeNavigate2
    Lparameters pdisp, url, flags, targetframename, postdata, headers, Cancel
    *  oFrm = This.Object.Document.myForm
    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.Name = "Treeview"
              lcVals = lcVals + "Name :" + oElem.Name + "/Value:"+;
                Iif(!Isnull(oElem.SelectedItem),;
                oElem.SelectedItem.Fullpath,"NULL") + Chr(13)
            Else
              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
            Endif
            oElem = .Null.
          Endfor
        Endif
        oFrm = .Null.
      Endfor
    Endif
    Cancel = .T.  && prevents actual navigation
    lcVals = lcVals + Chr(13)+Chr(10)+;
      'Submitted by:'+Transform(This.Object.Document.All("submitter").Value)
    Messagebox(lcVals)
  Endproc

  Procedure htmlviewer.Refresh
    Nodefault
  Endproc
Enddefine
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform