Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How call a procedure when user clicks TIWURL
(05-24-2022, 08:22 PM)DEKETO Wrote: I'm writing an IntraWeb 14 application in Delphi and I want to reset and enable my input form when the user clicks on the URL to the instructions page.

However, TIWURL does not have an OnClick or OnAsyncClick event.  OnAsyncClick shows up via Code Completion, but I can't actually access and use it.  I know that there is an OnClick event in the ScriptEvents property, but I know nothing of Javascript and have no idea of how to write a script to call my Delphi code procedure.  My best guess is that I need to define a callback function, but I have no idea of how to call it via Javascript, and even better, how to pass a parameter back to Delphi from Javascript.

Does anyone know how to do this?  A simple example would be awesome!

Thanks in advance,


Hi George,

it is very simple to implement.

This is what you add to your onClick event in ScriptEvents property:

It is basically 1 line of very simple JavaScript. The first parameter is the name of your callback (the one that you will declare in your Delphi code, ahead), and the second is a string containing one or more parameters. Each parameter should be like name=value, separated by an ampersand &. Very simple.

ajaxCall("MyCallback", "param1=this is a string parameter&param2=2");

Now, in your Delphi code you do this:

1- Declare MyCallback method such as:

  TIWForm1 = class(TIWAppForm)
    procedure IWAppFormCreate(Sender: TObject);
    procedure MyCallback(EventParams: TStringList);


{$R *.dfm}

procedure TIWForm1.MyCallback(EventParams: TStringList);
  Param1: string;
  Param2: Integer;
  Param1 := EventParams.Values['Param1'];
  Param2 := StrToIntDef(EventParams.Values['Param2'], -1);

procedure TIWForm1.IWAppFormCreate(Sender: TObject);
  WebApplication.RegisterCallBack('MyCallback', MyCallback);

You can give name the callback differently, of course.

Please let me know if you need more info about this

Messages In This Thread
RE: How call a procedure when user clicks TIWURL - by Alexandre Machado - 05-27-2022, 03:16 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)