X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Javascript function problem in template (https://forum.x-cart.com/showthread.php?t=34325)

creativearc 10-02-2007 01:53 PM

Javascript function problem in template
 
I've got this code inside one of my templates:

Code:

<script language="javascript" type="text/javascript">
        function entercustomernumber(countnumber) {
                alert("The function ran");
        }
</script>


For some reason, when I look at the source code for the page, this is what is there:

Code:

<script language="javascript" type="text/javascript">
        function entercustomernumber(countnumber)</script>


Any idea why it is leaving out the { and } and everything in between?

gb2world 10-02-2007 07:41 PM

Re: Javascript function problem in template
 
The brackets {} are being interpreted as smarty tags - it is looking for smarty variables/code inside them.

You can maybe solve the problem by putting the function in separate .js file or adding it to the existing XCART js file? Maybe something like:
<script type="text/javascript" language="JavaScript1.2" src="my_scripts.js"></script>

then adding your functions to my_scripts.js

balinor 10-02-2007 07:56 PM

Re: Javascript function problem in template
 
Surround your JS with {literal} tags:

{literal}
Javascript here
{/literal}

That keeps Smarty from reading it as Smarty :)


All times are GMT -8. The time now is 02:07 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.