FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index mod_harbour Passing a variable to javescript
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Passing a variable to javescript
Posted: Sun Nov 03, 2019 11:21 AM

Dear Antonio,

passing a variable to javescript I use:

<s cript>
var cTimeDate = <?prg f_timeDate() ?>
</s cript>

function f_timeDate()
local cDatum_Zeit := ""

cDatum_Zeit := "'" + dtoC(date()) + " " + time() + "'"
? cDatum_Zeit

return cDatum_Zeit

//----------------------------------------------------------------//

I seems to me that function is read 2 times. Is this the correct way to get variables from Harbour to JS.

Best regards
Otto

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Passing a variable to javescript
Posted: Sun Nov 03, 2019 11:35 AM
A simpler way:

Code (fw): Select all Collapse
<s cript>
var cTimeDate = '{{dtoC(date()) + " " + time()}}';
</s cript>
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Passing a variable to javescript
Posted: Sun Nov 03, 2019 01:47 PM

Dear Antonio,
this is only a sample. Sometimes you have very functions with many lines. Should we program a mechanism that a functions does not execute on loading the page at first.
And it yes how can this be done.
Best regards
Otto

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Passing a variable to javescript
Posted: Mon Nov 04, 2019 11:09 AM

Dear Otto,

> Should we program a mechanism that a functions does not execute on loading the page at first

It will always execute on loading the page at first only

If you want to execute Harbour code later on, then you need to call the server again using Ajax (jquery)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion