Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Browser Control - How to submit
Message
De
06/04/2004 10:02:12
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
06/04/2004 09:46:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00892552
Message ID:
00892591
Vues:
14
This message has been marked as the solution to the initial question of the thread.
Here is a little sample for HTML in VFP way - also jscript for fun :)
* Create test htm
Text to m.Test noshow
<html>
<head>
<title>New User Sign Up</title>
<script language="JavaScript">
function myForm_Validator(theForm)
{
  if (theForm.ID.value.length != 10)
  {
    alert("Please enter 10 digits in the \"Id\" field.");
    theForm.ID.focus();
    return (false);
  }

  var checkOK = "0123456789-,";
  var checkStr = theForm.ID.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"ID\" field.");
    theForm.ID.focus();
    return (false);
  }
  document.location.href = 'nowhere.htm';
  return (true);
}
</script>
</head>
<body BACKGROUND=background.jpg>
<h1 align="Center"><font color="#000080">New User Sign Up</font></h1>
<form method="POST" action="file://c:/myDummy.htm" onsubmit="return myForm_Validator(this);" 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>
  <p>
  <input type="submit" value="Submit" name="B1">
  <input type="reset" value="Reset" name="B2">
  </p>
</form>
<p></BODY>
</HTML>
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
Cetin

>Cetin,
>I considered a grid and I guess thats what I will do :-) since I don't know how to submit.
>I was hoping someone out ther did somthing like that and could give me some hint.
>A simple form is not simple if you have to allow for many templates with many different inputs
>
>Peter
>
>>>I am working on a project where I have a screen with varying numbers of input controls.
>>>The values will end up in word docs. So a document coud require the fill of a couple of variables or as many of 50 to 60 variables (those are govenment forms etc.)
>>> I considered a grid, adding controls ato a form ar runtime, but I think the browser control with html would be the most appropriate here.
>>>But how can I sumbit the data to VFP. Without IIS?
>>>
>>>Any ideas anyone?
>>>
>>>Thanks
>>>Peter
>>
>>Peter,
>>From within VFP ? If so use a web browser control in form and intercept navigate to collect input values.
>>If not then a simple submit button with javascript would do. You don't need IIS as far as you do it with HTM.
>>PS:If from VFP why not grid or a simple entry form :)
>>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