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

adding a javascript clock in a template

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 05-12-2005, 06:25 AM
  NightFire's Avatar 
NightFire NightFire is offline
 

X-Adept
  
Join Date: Jul 2004
Location: The Netherlands
Posts: 561
 

Default adding a javascript clock in a template

Hello,

I'm trying to add a javascript clock into the template: /customer/top_menu.tpl

This is the code:

Code:
<html> <body> <div align="center"> <center> <table border="0"> <tr> <td> <script language="javascript"> <!-- document.write('<input onSelectstart="return false;" style="background-color: #000000; cursor: default; color: #00ff00; border: 3px ridge #CCFFCC; font-family: "times" system" value="Loading..." type="text" name="klokje" size="44" readonly>') function geefdeklok() // verander hierboven de kleuren van het klokje, alsmede de kleur van de omlijning, achtergrond { var klok = new Date() var dagen = klok.getDate() if(dagen<10) dagen = "0" + dagen var maanden = klok.getMonth() + 1 if(maanden<10) maanden = "0" + maanden var jaren = klok.getFullYear() var uren = klok.getHours() if(uren<10) uren = "0" + uren var minuten = klok.getMinutes() if(minuten<10) minuten = "0" + minuten var seconden = klok.getSeconds() if(seconden<10) seconden = "0" + seconden var detijd = dagen+"-"+maanden+"-"+jaren+" en de tijd is "+uren+":"+minuten+":"+seconden; klokje.value = "Vandaag is het " + detijd; } setInterval("geefdeklok()", 1000) // --> </script> </td> </tr> </table> </center> </div> </body> </html>

But I'm getting an error in the template.
What I'm doing wrong?
__________________
Best regards,
Niki Buitenrust Hettema

X-Cart Gold 4.1.8 (Live & Loaded)
Royal Bhaktapur: Handmade products from Nepal - Pashmina's, scarfs, shawls, stola's and more...
Reply With Quote
  #2  
Old 05-12-2005, 06:47 AM
 
balinor balinor is offline
 

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

Default

You need to put {literal} tags around the script:

{literal}insert javascript here {/literal}
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 05-12-2005, 08:53 AM
  dalmuti's Avatar 
dalmuti dalmuti is offline
 

eXpert
  
Join Date: Oct 2004
Location: Kansas
Posts: 343
 

Default

Code:
{literal} <script language="javascript"> <!-- document.write('<input onSelectstart="return false;" style="background-color: #000000; cursor: default; color: #00ff00; border: 3px ridge #CCFFCC; font-family: "times" system" value="Loading..." type="text" name="klokje" size="44" readonly>') function geefdeklok() // verander hierboven de kleuren van het klokje, alsmede de kleur van de omlijning, achtergrond { var klok = new Date() var dagen = klok.getDate() if(dagen<10) dagen = "0" + dagen var maanden = klok.getMonth() + 1 if(maanden<10) maanden = "0" + maanden var jaren = klok.getFullYear() var uren = klok.getHours() if(uren<10) uren = "0" + uren var minuten = klok.getMinutes() if(minuten<10) minuten = "0" + minuten var seconden = klok.getSeconds() if(seconden<10) seconden = "0" + seconden var detijd = dagen+"-"+maanden+"-"+jaren+" en de tijd is "+uren+":"+minuten+":"+seconden; klokje.value = "Vandaag is het " + detijd; } setInterval("geefdeklok()", 1000) // --> </script> {/literal}

I usually create a template (like time_js.tpl) as above.....then call that template as: {include file="time_js.tpl"} as below

Code:
<html> <body> <div align="center"> <center> <table border="0"> <tr> <td> {include file="time_js.tpl"} </td> </tr> </table> </center> </div> </body> </html>

Hope that helps....

Louise
__________________
Louise

Studio 57 Designs - X-Cart Customization
Providing X-Cart Services since 2004
Hottest Blog Directory - Submit Your Blog for a Free Listing
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 03:44 PM.

   

 
X-Cart forums © 2001-2020