View Single Post
  #7  
Old 02-07-2020, 12:07 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

Default Re: Having trouble modifying a smarty variable inside javascript

The only thing I can think of is that the smarty expression is running regardless of the js code. I think in the newer versions you don't even have to use the literal tag if they are on their own line. So basically you have the last one overwriting even though you think it shouldn't run.


There is no need to do this though.


Code:
{assign var="testB" value=false } {* initial value is assigned *} <script> var test; test = Math.round(Math.random()) == 1; if (test) {ldelim} {assign var="testB" value=true} {rdelim} </script>


You can even inline the first 2 lines so it is like

var test = Math.round(Math.random()) == 1


See if this works
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote