View Single Post
Old 02-07-2020, 11:32 AM
simetria simetria is offline

Advanced Member
Join Date: Jul 2013
Posts: 77

Default Re: Having trouble modifying a smarty variable inside javascript

I just tried your suggestion and same outcome...

{assign var= "testB" value= false } <script language="JavaScript" type="text/JavaScript"> {literal} let randNum = Math.round(Math.random()); if(randNum == 1){ {/literal} "{assign var='testB' value=true}" {literal} } else { {/literal} "{assign var='testB' value=false}" {literal} } console.log( randNum ); console.log( {/literal} "{$testB}" {literal} ); {/literal} </script>

This code will always - still - return the assigned "testB" from inside the else.

Even if I remove the initial assign - outside the js - I still get the same result.
Reply With Quote