php - Javascript variable and smarty -
i trying javascript smarty , using javascript variable , checking if value contained within smarty array.
below code have
if (object.data[i].application === selectedapplication || {if isset($applications) && $applications|@count > 0} true {else} false {/if}) { {if not isset($applications)} $("#cboapplications").append("<option selected value=\""+object.data[i].id+"\">"+object.data[i].application+"</option>"); {else} {if '9'|in_array:$applications} console.log("id " + id + " in array"); $("#cboapplications").append("<option selected value=\""+object.data[i].id+"\">"+object.data[i].application+"</option>"); {else} console.log("id " + id + " not in array"); $("#cboapplications").append("<option value=\""+object.data[i].id+"\">"+object.data[i].application+"</option>"); {/if} {/if} }
the issue having {if '9'|in_array:$applications}
. @ moment i've hardcoded value instead of using javascript variable test same results.
below array looks when printed inside smarty
array ( 0 => '9', )
there multiple values in list box cboapplications
have value of 8, 5, 6, 9 , 10.
for reason, though 9 in $applications array, console.log acting if every single item inside array, not 9.
thanks can provide.
you have use {literal}
in smarty javascript. example:
{literal} <script type="text/javascript"> document.write("{/literal}{$text}{literal}"); </script> {/literal}
for more information, see smarty documentation.
Comments
Post a Comment