Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Want simple JS demo
#18
My Notebook config:
Dell Inspiron 5480
Intel Core i5-8265U 1.60GHz, 24GB Ram
Windows 10 64bits Home Edition, v.1903.18362.295 (Taiwan)

(08-19-2019, 03:35 AM)DanBarclay Wrote: Some fresh code for the demo Jose provided for you.  Replace his two procedures with the following.  They do things  more than once, different ways, but provide your original request for timezone offset in addition to showing the callback with comments.

Code:
procedure TIWForm1.clbkGridSel(aParams: TStrings );
begin
  // value of "Selection was sent by callback function, get it from parameters
  fGridSelection := aParams.Values['Selection'];

  // Now put it back into the IWEdit1 control if you want (or use it here on the Delphi side).
  //   It is in a Delphi variable now so do what you want with it.
  WebApplication.
  CallBackResponse.
    AddJavaScriptToExecuteAsCDATA( 'document.getElementById("IWEDIT1").value = "' + fGridSelection + '"' );

  //  Show the value on the way out.
  WebApplication.ShowNotification( fGridSelection );
  // Put the timezone offset as caption of the button, on the server side
  IWButton1.caption:=fGridSelection;
  webapplication.showmessage('1234 for fun');
end;

procedure TIWForm1.IWButton1AsyncClick(Sender: TObject;
  EventParams: TStringList);
begin

  // Use the async click to execute a callback function on the browser side.
  //  Compute and send Timezone Offset minutes and pass as parameter
  //  Also put it in IWEdit1, using javascript on the browser side.
  WebApplication.
  CallBackResponse.
    AddJavaScriptToExecute(
  'var d = new Date();' + sLineBreak +
  'var tn = d.getTimezoneOffset();' + sLineBreak +
  'document.getElementById("IWEDIT1").value = tn;' + sLineBreak+
  'ajaxCall("clbkGridSel", "Selection="+tn, false);'
  );

end;

It's not pretty or efficient, but see if that helps understanding.

Dan
Dan,

The code is nothing show, no pop up message, IWedit1 nothing changed value.
No any error message. Silent like in deep ocean.
Reply


Messages In This Thread
Want simple JS demo - by Kristy - 08-16-2019, 06:54 AM
RE: Want simple JS demo - by Kristy - 08-16-2019, 08:50 AM
RE: Want simple JS demo - by Jose Nilton Pace - 08-16-2019, 11:17 AM
RE: Want simple JS demo - by kudzu - 08-16-2019, 12:22 PM
RE: Want simple JS demo - by Kristy - 08-16-2019, 01:25 PM
RE: Want simple JS demo - by Kristy - 08-17-2019, 03:53 AM
RE: Want simple JS demo - by Jose Nilton Pace - 08-17-2019, 09:38 PM
RE: Want simple JS demo - by Kristy - 08-18-2019, 01:17 AM
RE: Want simple JS demo - by Kristy - 08-18-2019, 06:28 AM
RE: Want simple JS demo - by DanBarclay - 08-18-2019, 06:55 AM
RE: Want simple JS demo - by Kristy - 08-18-2019, 07:47 AM
RE: Want simple JS demo - by Alexandre Machado - 08-18-2019, 09:45 PM
RE: Want simple JS demo - by Kristy - 08-19-2019, 03:14 AM
RE: Want simple JS demo - by DanBarclay - 08-19-2019, 03:35 AM
RE: Want simple JS demo - by DanBarclay - 08-18-2019, 05:54 PM
RE: Want simple JS demo - by kudzu - 08-18-2019, 06:51 PM
RE: Want simple JS demo - by Alexandre Machado - 08-19-2019, 03:25 AM
RE: Want simple JS demo - by Kristy - 08-19-2019, 05:02 AM
RE: Want simple JS demo - by DanBarclay - 08-19-2019, 05:14 AM
RE: Want simple JS demo - by Kristy - 08-19-2019, 06:35 AM
RE: Want simple JS demo - by Alexandre Machado - 08-19-2019, 08:24 AM
RE: Want simple JS demo - by Kristy - 08-19-2019, 09:56 AM
RE: Want simple JS demo - by Alexandre Machado - 08-21-2019, 02:44 AM
RE: Want simple JS demo - by Kristy - 08-21-2019, 03:13 AM
RE: Want simple JS demo - by DanBarclay - 08-21-2019, 03:24 AM
RE: Want simple JS demo - by kudzu - 08-21-2019, 02:57 PM
RE: Want simple JS demo - by Kristy - 08-23-2019, 04:29 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)