Change global variable in Javascript

<< Click to Display Table of Contents >>

Navigation:  Forum >

Change global variable in Javascript

Forum link

 


 

07-19-2019, 07:54 AM:

 

I have in my HTML template javascript global variable. How change this value?

 

var link="c:\temp\test1.pdf"; -> var link="c:\temp\test2.pdf"; 

 

Not work this: WebApplication.CallBackResponse.AddJavaScriptToExecute('link="c:\temp\test2.pdf";');

 


 

07-19-2019, 10:18 AM:

 

Hi Matija, try:

 

Code:

 

WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA( 'var link="c:\temp\test2.pdf";' );

 

 

 


 

09-06-2021, 11:49 AM:

 

(07-19-2019, 10:18 AM)Jose Nilton Pace Wrote: [ -> ]Hi Matija, try:

 

Code:

 

WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA( 'var link="c:\temp\test2.pdf";' );

 

 

 

How change JS variable define in mastertemplate.html for all forms? Value for language link (JSON -> datatables)

 


 

09-14-2021, 06:18 AM:

 

We need an example. If the variable is already declared in the browser page context, you can just update the value of the variable, example:

 

Code:

 

WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA( 'link="c:\temp\test2.pdf";' );

 

 

 

This will update a variable named "link" declared previously somehwere in your page. Any javascript code that makes use of this link variable will get the updated content