Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Javascript function problem in template

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-02-2007, 01:53 PM
 
creativearc creativearc is offline
 

Advanced Member
  
Join Date: May 2007
Posts: 34
 

Default 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?
__________________
CreativeArc
---------------
X-Cart Pro
Version: 4.1.8
Reply With Quote
  #2  
Old 10-02-2007, 07:41 PM
  gb2world's Avatar 
gb2world gb2world is offline
 

X-Wizard
  
Join Date: May 2006
Location: Austin, TX
Posts: 1,970
 

Default 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
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold
(CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module)
Reply With Quote
  #3  
Old 10-02-2007, 07:56 PM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Javascript function problem in template

Surround your JS with {literal} tags:

{literal}
Javascript here
{/literal}

That keeps Smarty from reading it as Smarty
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:13 PM.

   

 
X-Cart forums © 2001-2020