huayan889 Posted May 6, 2021 Share Posted May 6, 2021 How to Get JS function ADD(10,2) result? procedure TMainForm.UniFormCreate(Sender: TObject); begin Script.text:= 'function add(x,y) {'+ ' return x+y;' + '}'; showmessageN(add(10,2));//display result= 12 end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 6, 2021 Share Posted May 6, 2021 4 minutes ago, huayan889 said: showmessageN(add(10,2));//display result= 12 Hello, For what purpose, sorry? Quote Link to comment Share on other sites More sharing options...
huayan889 Posted May 6, 2021 Author Share Posted May 6, 2021 Just now, Sherzod said: Hello, For what purpose, sorry? get add function(js code) result Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 6, 2021 Share Posted May 6, 2021 1 minute ago, huayan889 said: get add function(js code) result I understood you, but you won't just use the addition function, will you? Quote Link to comment Share on other sites More sharing options...
huayan889 Posted May 6, 2021 Author Share Posted May 6, 2021 Just now, Sherzod said: I understood you, but you won't just use the addition function, will you? I want to call JS's encryption algorithm and return the result of encryption or decryption Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 6, 2021 Share Posted May 6, 2021 3 minutes ago, huayan889 said: I want to call JS's encryption algorithm and return the result of encryption or decryption Well, something like we did in your post. Quote Link to comment Share on other sites More sharing options...
huayan889 Posted May 6, 2021 Author Share Posted May 6, 2021 Just now, Sherzod said: Well, something like we did in your post. It's OK to assign a value to the control, but now I want to return the result to the specified variable Quote Link to comment Share on other sites More sharing options...
huayan889 Posted May 6, 2021 Author Share Posted May 6, 2021 15 minutes ago, huayan889 said: It's OK to assign a value to the control, but now I want to return the result to the specified variable Something like this,Delphi Code call js MD5 function, Can it be realized? UniQuery1.SQL.Text := 'select * from ss_customer_info where (customer_id=' + chr(39) + UniEdit1.Text + chr(39) + ') and (admin_id =' + chr(39) + admin_id.Text + chr(39) + ') and (admin_pass=' + chr(39) + MD5(fromCode(FpKey)) + chr(39) + ')'; UniQuery1.Open; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 6, 2021 Share Posted May 6, 2021 Which version of Delphi are you using? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 6, 2021 Share Posted May 6, 2021 You can use it like this: Uses ... IdHash, IdHashMessageDigest; with TIdHashMessageDigest5.Create do try MD5HashStr := HashStringAsHex(edPass.Text); finally Free; end; Quote Link to comment Share on other sites More sharing options...
huayan889 Posted May 6, 2021 Author Share Posted May 6, 2021 6 minutes ago, Sherzod said: You can use it like this: Uses ... IdHash, IdHashMessageDigest; with TIdHashMessageDigest5.Create do try MD5HashStr := HashStringAsHex(edPass.Text); finally Free; end; MD5 is just an example, I need to use other encryption algorithms Quote Link to comment Share on other sites More sharing options...
irigsoft Posted May 6, 2021 Share Posted May 6, 2021 . Quote Link to comment Share on other sites More sharing options...
huayan889 Posted May 6, 2021 Author Share Posted May 6, 2021 I mean, is there any way to call JS function in Delphi code to return the result. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 6, 2021 Share Posted May 6, 2021 Just now, huayan889 said: I mean, is there any way to call JS function in Delphi code to return the result. Well, the algorithm is this: JS fn call (client side, use ajaxRequest to send data to server) -> Handling OnAjaxEvent (server side) Quote Link to comment Share on other sites More sharing options...
huayan889 Posted May 6, 2021 Author Share Posted May 6, 2021 5 minutes ago, Sherzod said: Well, the algorithm is this: JS fn call (client side, use ajaxRequest to send data to server) -> Handling OnAjaxEvent (server side) Thank. Quote Link to comment Share on other sites More sharing options...
dmzn Posted August 14, 2021 Share Posted August 14, 2021 procedure TfFormFilterHistory.UniButton1Click(Sender: TObject); var nStr: string; begin nStr := 'var t1=%s.getEditorBody().outerText;'+ //1.call function 'ajaxRequest(%s.form, ''getHTMLtext'', [''t1=''+t1]);'; //2.send result to server nStr := Format(nStr, [Memo1.JSName, self.Name]); UniSession.SendResponse(nStr); UniSession.Synchronize; // MainModule.EnableSynchronousOperations=true,here is important ShowMessageN(FText); //show result end; procedure TfFormFilterHistory.UniFormAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName='getHTMLtext' then begin FText:=Params.Values['t1']; //3.receive result end; end; 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.