Atozed Forums
Change global variable in Javascript - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: Change global variable in Javascript (/thread-1140.html)



Change global variable in Javascript - matija - 07-19-2019

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";');


RE: Change global variable in Javascript - Jose Nilton Pace - 07-19-2019

Hi Matija, try:
Code:
WebApplication.CallBackResponse.AddJavaScriptToExecuteAsCDATA( 'var link="c:\temp\test2.pdf";' );



RE: Change global variable in Javascript - matija - 09-06-2021

(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)


RE: Change global variable in Javascript - Alexandre Machado - 09-14-2021

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