I have such a script, it works:

{literal} <script type="text/javascript"> function changelicense() { var licensetype = document.getElementById("licensetype").value; if (licensetype == "regular") { chooseLicence('regular', '**{$item.price|string_format:"%.0f"}**', '**{$item.prepaid_price|string_format:"%.0f"}**', 'block') } if (licensetype == "extended") { chooseLicence('extended', '**{$item.extended_price|string_format:"%.0f"}**', '**{$item.extended_price|string_format:"%.0f"}**', 'none') } } </script> {/literal} 

But how to make the value of {$ item.price | string_format: "%. 0f"} written in numbers, as it should be? While I am getting in the meaning exactly this inscription

  • Those. Is php format really stuck in js? - Nikolay

1 answer 1

First, check if the change to ordinary quotes' for double quotes ".
Secondly, php is executed on the server, before javascript can be executed at all. Understandably, you can pervert and come up with a detour, but it will not be right a bit. In principle, it depends on the task of course ...