Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP to HTML forms and back again (revisited) 4

Status
Not open for further replies.

KarenLloyd

Programmer
Nov 23, 2005
141
GB
Hello my Gurus...

It’s been at least six months. I hope that all is well with you. I need to ask for your advice again relating to a past post … VFP to HTML forms and back again - mobile development
It’s for the next stage of the project tho, I have been through many degrees of separation - now it’s time to come back to Visual FoxPro. (No more online Lint =D for a while I hope). Please bear with me…

I have been working on a Mobile Forms "App", using HTML5 & JavaScript for client-side processing and local data storage with some PHP and Web SQL for the login and exchange of form data with the office (via a Website/App Server) when connected to the Internet.

This is all going back to the ideas that I started working with over a year ago. I know that I may be lightyears behind, but being a lone star I’m working at a different pace. (If you know how limited my web dev experience was six months ago then you'll understand when I say it's been quite an "adventure!")

I am now at the point where I send forms to an app server where they get collected and updated from mobile devices and then uploaded when complete. My VFP app then downloads submitted form data via FTP as individual XML files and processes them into a log in the server database system… all good so far…

But this brings me to my next “challenge”

I can load the submitted form values into a temp version of an html page… from VFP and I can use an ActiveX control in VFP to view the HTML form (web page) in an automated browser window… from my limited tests so far.

BUT – instead of using JavaScript in the browser window - Can I use a VFP function to work on a form command button to save the html file with the form values, so that I can extract the values via another process and write them back to the VFP data files?

It may be just that I’m reaching a wall time-wise, and I’m overlooking something obvious, or just that the return to my true programming language without the //comments and semi-colons; everywhere has left me a little lost and brain damaged.

Before I go and catch up on some overdue sleep I just wondered and hoped if maybe any of you super beings could please send me some links to help and enlighten me.

As always I will be eternally grateful…

Best wishes

Karen
 
In short: that's possible.

I can't explain in short, what Rick Strahl has already written about interfacing the internet explorer, but also the web browser control, including a way to or from javascript and/or the document object model (DOM), to read or set html form values.

So you better have a read of
More specific, the section
Bye, Olaf.
 
Karen,

In addition to the method that Olaf suggested, you can use the web brower's control ExecWB method to save the page in a physcial HTML file. You can then use VFP's various parsing and string-handling functions to extract the form data from that file.

I'm not sure if this approach is better than the one Olaf suggested. It might turn out to be more work. But you might at least want to consider it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Olaf and Hi Mike

This gives me just what I needed to be able start the day in the right direction.

Thank you both very much.

Best wishes

Karen

 
Karen ,

you can also use custom attributes to greatly extend these ideas. For example , the minimal code below has attributes defined for biz , address1 , address2. If using a HTML editor , it will complain about unsupported tags , ignore it. In HTML5 , custom attrinutes are further extended by using data- prefix e.g. data-biz data-address1 etc , but that only helps if using Javascript , which you dont want/need here.

<body>
<label>Account</label>
<input id="Account" value="My Account" biz="My Biz" address1="My Street" address2="My Town" >
</body>

In your VFP , place a browser control wb1 on the form , navigate to that html and do something like below. The values will list to the screen, proving the link works.

Here you are using the DOM getAttribute function which has always existed, so in effect this allows you to create a data-table that talks back/forth from html/vfp

o=thisform.wb1
acti screen
? o.Document.all.account.getAttribute("biz")
? o.Document.all.account.getAttribute("address1")
? o.Document.all.account.getAttribute("address2")

You will need of course to build up the attributes on the initial HTML form , that will just be a bit of PHP ( or whatever script language you use, ASP MVC with the Razor view engine is awesome even though it does use semi.colons )

sean m



thanks to Olaf for pointing to the Rick Strhal article + a little googling to find out about using getAttribute

 
just to clarify ,you can also just use the value of the element e.g.

? o.Document.all.account.value
will return "My Account"

so you can just read seperate input field values on the form, but using attributes is much more " database style
 
Thanks, Mike Gagnon, for the FoxInCloud link - I will definately be taking a look at this later on.
 
Hi Clipper01

I've made some real progress with this today using the _webview class on a form, loading the values from my data first to show the partially completed web form inside VFP.

I have also found just now, thanks to your tip, that I can use the DOM's getElementById('name').value to get all the data back from the html form. Great stuff - I'm on a roll :D

Thank you very much Sean!

Best wishes

Karen

 
Hi Olaf

I have now read through a lot more of the West Wind Shell API page. I just wanted to thank you again, the bits about traversing the document nodes are especially useful and I have been able to extract the form data in the same way as I would normally do using JavaScript.


Hi Mike

The saving of the document as HTML is not so vital at this stage now that I know I can work with the DOM from inside VFP. However, there will be some forms that benefit from this method later down the line and so I will dig in further with the ExecWB method when the time comes.


Thanks again to everyone for your guidance. I am always grateful to you for your help.

Best wishes

Karen
 
The saving of the document as HTML is not so vital at this stage now that I know I can work with the DOM from inside VFP. However, there will be some forms that benefit from this method later down the line and so I will dig in further with the ExecWB method when the time comes.

Given that you're comfortable working with the DOM, it would be easier to use the OuterHTML element to retrieve the entire page, rather than saving it to a file. But the end result is the same.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top