Functions, parameters and DOM

Coordinator
Aug 15, 2012 at 8:40 PM

Can you pass a parameter in a function where it's an actual element of your HTML? i.e

<%=myfunction(document.tittle)%>

If, yes, how can you construct it?  The example above gives a syntax error obviously, putting the parameter in quotes will return document.tittle instead of the actual value on it.

<%=myfunction("document.tittle")%>

document.tittle
Coordinator
Aug 16, 2012 at 12:24 AM

I'm not sure you can do this from any server-side language.  I searched for an example in PHP and found this:

"You can't transfer a JS variable to PHP because PHP is server side, and it's not processing by the time the page is spit out to the browser."

A good rule of thumb is to google for a PHP example of whatever you want to do in AVFP.  If it can be done in PHP, you can do it in AVFP..

Aug 16, 2012 at 3:24 AM

Anything inside <%= %> is executed by foxpro on the server. You have access to anything a regular vfp program would have access on that machine and all the environment that active vfp puts at your server code disposition as objects. <document.title> is something you can access on your browser using javascript or the browser object control/application. To call myfunction( document.title ) on server side  you need to pass document.title as a parameter to your active vfp page.

Marco

Coordinator
Aug 16, 2012 at 3:06 PM
Edited Aug 16, 2012 at 3:06 PM
claudefox wrote:

I'm not sure you can do this from any server-side language.  I searched for an example in PHP and found this:

"You can't transfer a JS variable to PHP because PHP is server side, and it's not processing by the time the page is spit out to the browser."

A good rule of thumb is to google for a PHP example of whatever you want to do in AVFP.  If it can be done in PHP, you can do it in AVFP..

Yeah, that's what I found yesterday as well... similar sample in an ASP environment from stackoverflow:

http://stackoverflow.com/a/3441872