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

Join Date: Apr 2007
Posts: 14,098

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.

{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
Web Development
Reply With Quote