wkotze Posted January 29, 2022 Share Posted January 29, 2022 Hi Guys, how can i get the value from a script back into a local variable procedure blabla; var x1 : string; begin UniSession.AddJS(' var x = "unigui" ; '); // i want js x returned into variablex1 thank you Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 29, 2022 Share Posted January 29, 2022 19 minutes ago, wkotze said: how can i get the value from a script back into a local variable Hello, Using ajaxRequest Quote Link to comment Share on other sites More sharing options...
wkotze Posted January 29, 2022 Author Share Posted January 29, 2022 sorry Sherzod, can you please provide some code as in simple example i've used thank you!! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 29, 2022 Share Posted January 29, 2022 There are many examples on the forum, use the search. Your case is not clear, please clarify, we will try to give an example. Quote Link to comment Share on other sites More sharing options...
wkotze Posted January 29, 2022 Author Share Posted January 29, 2022 sorry Sherzod, examples not clear. i am trying to display both the server time and the local time to thuser procedure TMainmForm.lbltimeClick(Sender: TObject); var servertime,devicetime : string; begin ... servertime := formatdatetime('hh:mm:ss',now) // javascript call to put local time into 'jsdatestr' // UniSession.AddJS(' var ldate = new Date(); var jsdatestr = ldate.toLocaleTimeString("EN-us").substring(0,8); '); <-- is UniSession.AddJS event the correct call ? devicetime := ??? <--- i need jsdatestr from JS above here uniGUIDialogs.ShowMessageN( 'server time is ' + servertime + ', your local time is ' + devicetime ) ... end Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 29, 2022 Share Posted January 29, 2022 5 minutes ago, wkotze said: uniGUIDialogs.ShowMessageN( 'server time is ' + servertime + ', your local time is ' + devicetime ) Okay. I will try. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 29, 2022 Share Posted January 29, 2022 As I understood you want this on button click. Quote Link to comment Share on other sites More sharing options...
wkotze Posted January 29, 2022 Author Share Posted January 29, 2022 yes Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 29, 2022 Share Posted January 29, 2022 13 minutes ago, wkotze said: yes 1. UniButton1.ClientEvents.ExtEvents -> function click(sender, e, eOpts) { ajaxRequest(sender, 'getLocalTime', ['time='+new Date().toLocaleTimeString()]); } 2. UniButton1.OnAjaxEvent -> procedure TMainForm.UniButton1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = 'getLocalTime' then begin (Sender as TUniButton).CustomAttribs.Values['clienttime'] := Params.Values['time']; end; end; 3. UniButton1.OnClick -> procedure TMainForm.UniButton1Click(Sender: TObject); begin ShowMessage((Sender as TUniButton).CustomAttribs.Values['clienttime']) end; Quote Link to comment Share on other sites More sharing options...
wkotze Posted January 30, 2022 Author Share Posted January 30, 2022 thank you, very helpfull!! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.