Recent

Author Topic: Call a function from html  (Read 649 times)

cappe

  • Full Member
  • ***
  • Posts: 109
Call a function from html
« on: September 03, 2019, 12:11:03 pm »
Hello
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)

example
html
 <input type="button" class="form-control" id="btn3" value="direct mode" onclick="Btn1Click();"/>

and the Btn1Click function write it with pas2js.
example
function Btn1Click(aEvent: TJSMouseEvent): boolean;
begin
  // 
end;

How can I do?

Added:
I would like to know how to do it because the Btn1Click function can be reached from outside the js file of pas2js.
« Last Edit: September 03, 2019, 01:24:35 pm by cappe »

Thaddy

  • Hero Member
  • *****
  • Posts: 10139
Re: Call a function from html
« Reply #1 on: September 03, 2019, 01:46:36 pm »
???? As long as rtl.js can be found you should not have no problems at all? Can you be more specific??
I am more like donkey than shrek

cappe

  • Full Member
  • ***
  • Posts: 109
Re: Call a function from html
« Reply #2 on: September 03, 2019, 02:06:49 pm »
I probably miss some pas2js programming base

in pas2js I create a function like this:
function Btn1Click(aEvent: TJSMouseEvent): boolean;
begin
  //
end;

I compile the project and I return project1.js as correct.

Now the call to this works I don't want to do it from the pas2js project (like button1.onclick := @Btn1Click;), but from the html file

As an example
<input type="button" class="form-control" id="btn3" value="direct mode" onclick="Btn1Click();"/>

The problem that the html file does not find me Btn1Click () ;. So the question is how can I make Btn1Click to be reachable from the html file (so abroad for the pas2js project)?




« Last Edit: September 03, 2019, 02:13:29 pm by cappe »

 

TinyPortal © 2005-2018