Jump to content

Access Variable in ClientEvent


hendrang

Recommended Posts

Hi All,

 

Please help.

I am newbie in Web Application

 

I want the ClientEvent OnClick Execute ajaxRequest with EventName depend on an variable value declare in MainForm

 

For example :

 

Salary is variable declare in MainForm

 

function OnClick(sender, e)

{

if (Salary < 10000)

{

ajaxRequest(sender, 'Event1');

}

else

{

ajaxRequest(sender, 'Event2');

}

}

 

Please help me to correct the function above.

 

Thanks in advance.

Link to comment
Share on other sites

The easiest (but not the best) way is to create a hidden unilabel and store variable in its caption so you can access it in client browser.

The right way is to create your own "namespace" in javascript globals and store variables there with UniSession.AddJS(), something like this

 

window.MyVars = window.MyVars || {};
window.MyVars.Salary = 1000;

...

function OnClick(sender, e)
{
 if window.MyVars.Salary < 10000 then ...

Link to comment
Share on other sites

The easiest (but not the best) way is to create a hidden unilabel and store variable in its caption so you can access it in client browser.

The right way is to create your own "namespace" in javascript globals and store variables there with UniSession.AddJS(), something like this

 

window.MyVars = window.MyVars || {};
window.MyVars.Salary = 1000;

...

function OnClick(sender, e)
{
 if window.MyVars.Salary < 10000 then ...

 

Hi. Thanks for your help.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...