Wajeed Posted May 18, 2020 Share Posted May 18, 2020 Newbie to unigui and javascript, I am trying to pass variable from a unigui form to javascript.I tried two methods as discussed in forum First method on Mainform.oncreate Self.WebForm.JSInterface.JSAssign('myvar', [2356]); on same form button1 clientevents(ExtEvents) , I tried to access the variable function click(sender, e, eOpts) { var n1 = MainForm.windows.myvar; alert(n1); } nothing happens. ----------------- Second method on Mainform button click procedure TMainForm.UniButton2Click(Sender: TObject); begin UniApplication.UniSession.AddJS('var myVar = 1'); end; clientside(Extevents) function click(sender, e, eOpts) { var n1 = uniVars.myVar ; alert(n1); } i get undefined alert message at runtime when i click the button. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 18, 2020 Share Posted May 18, 2020 28 minutes ago, Wajeed said: First method on Mainform.oncreate Self.WebForm.JSInterface.JSAssign('myvar', [2356]); on same form button1 clientevents(ExtEvents) , I tried to access the variable function click(sender, e, eOpts) { var n1 = MainForm.windows.myvar; alert(n1); } nothing happens. 29 minutes ago, Wajeed said: var n1 = MainForm.windows.myvar; Correct - var n1 = MainForm.window.myvar; 1 Quote Link to comment Share on other sites More sharing options...
Wajeed Posted May 18, 2020 Author Share Posted May 18, 2020 Thanks, works perfect. Now, i cannot do the same in Uniframe. Self.WebForm.JSInterface.JSAssign('myvar', [2356]); gives error undeclared indentifier webform. may be i am missing some files in uses class. please help Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 18, 2020 Share Posted May 18, 2020 12 minutes ago, Wajeed said: WebForm Try OwnerWebForm. Quote Link to comment Share on other sites More sharing options...
Wajeed Posted May 18, 2020 Author Share Posted May 18, 2020 Thanks bro, 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.