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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...