I have a smarty variable assigned to false. Then within Javascript I will be running a function to return whether that smarty variable should change to true or stay false. At the moment I'm always getting the else portion of the js if statement.
This is a very simple example, but it gets the point across... If the random number generated is 1 change the smarty variable to true otherwise keep it at false.
Code:
{assign var= "testB" value= false }
<script language="JavaScript" type="text/JavaScript">
{literal}
let randNum = Math.round(Math.random());
if(randNum == 1){
{/literal} "{$testB = true}" {literal}
console.log('here');
} else {
{/literal} "{$testB = false}" {literal}
console.log('here2');
}
console.log( randNum );
console.log( {/literal} "{$testB}" {literal} );
{/literal}
</script>
When I run console.log() inside the if statements he shows me that it iterates through the if statement correctly, but the smarty variable will always change to false, or whatever I set it to inside the else portion.
So with the above code, if randNum is 1 it will console log 'here', but the smarty variable will be false - or whatever I set it to inside the else.
Thank you all.