Date:  08/31/2019 07:30:53 PM Msg ID:  004993
From:  Art Bergquist Thread:  004992
Subject:  Re: Call VFP function from JavaScript event
I see the following line in Examples\Authenticate.FWx:
    <a href="authenticate.fwx?<%=SYS(3)%>">Login</a><p>
and the following lines in Examples\CookieDemo.FWx:
    <h3>You have viewed this page <%= m.tot_hits%> time<%= IIF(m.tot_hits = 1, SPACE(0), 's')%></h3>
    <a href="CookieDemo.fwx?delete=1&<%=SYS(3)%>"><b>Delete cookie</b></a> |
<a href="CookieDemo.fwx?<%=SYS(3)%>"><b>Refresh</b></a>
so I know that you can call native VFP functions within "<%=" and "%>".
And this line in Examples\SessionDemo.FWx
<b>SessionID</b>: <%=Session.GetSessionID()%>&nbsp;&nbsp;&nbsp;&nbsp;
and this line in Examples\Upload.FWx:
   Value: <%=Request.Form("field1")%>
show that you can call a FoxWeb function (method) within "<%=" and "%>".
Sent by Art Bergquist on 08/31/2019 05:04:47 PM:
Hi, all.
I believe I can do this but am having difficulty getting it to work; I'm building up a string that contains an anchor (<a href ...>).  As part of that string, I'm trying to set up a JavaScript event handler so that when a user clicks on the anchor, it first calls a VFP function (and then goes to the URL specified in href):
onclick="<%= RecordDocument() %>"
RecordDocument.Prg contains the following code:
STRTOFILE('Test message', 'RecordDocument.Txt', .F.)
The problem is that when I click on an anchor that has its onclick defined as above, it doesn't appear to run RecordDocument.Prg (since RecordDocument.Txt doesn't get created).
I've also tried not including the equals sign, as follows:
onclick="<% RecordDocument() %>"

but that didn't work (and I don't believe that's the correct syntax anyway).

Has anyone ever tried doing something like this?

Art Bergquist