[Pas2js] Call a function from html
Michael Van Canneyt
michael at freepascal.org
Wed Sep 4 08:24:01 CEST 2019
On Tue, 3 Sep 2019, Gabriele Cappelletto via Pas2js wrote:
> I would like to find a way to call a function written with pas2js from
> html code (do not define onclick from pas2js, but call from html)
> ?<input type="button" class="form-control" id="btn3" value="direct mode"
All functions live under the top-level "pas" object, per unit.
should do it.
Here YourUnit and YourFunction are of course case sensitive.
If the function is in the main program, then you must write
with the identifier "program" in lowercase letters.
You must make sure that rtl.run() has been called when the page loads.
> and the Btn1Click function write it with pas2js.
> function Btn1Click(aEvent: TJSMouseEvent): boolean;
> ? //?
> How can I do?
Just write your function, and refer to it in the above manner.
More information about the Pas2js