|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Carnage Smarty Rookie
Joined: 05 Nov 2004 Posts: 7
|
Posted: Fri Nov 05, 2004 11:07 pm Post subject: Java Script und ein Smarty Problem |
|
|
Hi.
Ich habe leider ein kompliziertes Problem mit Smarty und meinem Skript. Und zwar besteht ein Grundgerüst, welches automatisch immer den Kopf+Mittelteil+Fuß der Site lädt. Nun muss aber ein Countdown-Skript welches in Java Script geschrieben ist und in der header.tpl ist aufgerufen werden.
Nun gibt es aber das Problem, dass Smarty diesen Header ja nicht mehr immer pro Datensatz einzeln (mit dem Command: {section name=id loop=$test}) aufruft, sondern nur einmal, wodurch nur einmal der Zähler bei einem Datensatz aktiviert/gestartet wird. Hier mal das Skript:
Header.tpl:
Code: |
....
{section name=id loop=$test}
{literal}
<script type="text/javascript">
var time = {$test[id].zeit};
function countdown() {
time--;
if (time == 0) {
text = 'Erledigt';
} else {
hour=Math.floor(time/(60*60));
rest=time%(60*60);
min=Math.floor(rest/60);
rest=rest%60;
text = hour + ":" + min + ":" + rest;
window.setTimeout('countdown()', 1000);
}
document.getElementById('time_div').firstChild.data = text;
}
</script>
{/literal}
{/section}
</head>
<body onLoad="countdown()">
|
test.tpl
Code: |
{section name=id loop=$test}
<tr>
<td>{$test[id].feld1}</td>
<td>{$test[id].feld2}</td>
<td>{$test[id].feld3}</td>
<td>{$test[id].feld4}</td>
<td>{$test[id].zeit}</td>
<td><div id="time_div">&</div></td> <<<< Hier sollte dann pro Datensatz die Zeit angezeigt werden (Countdown); die Zeit bekommt er in Sekunden aus einem Timestamp
</tr>
{/section}
|
Kann mir da jemand weiterhelfen ? |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Sat Nov 06, 2004 11:16 am Post subject: |
|
|
Code: |
{section name=id loop=$test}
{literal}
<script type="text/javascript">
var time = {/literal}{$test[id].zeit}{literal};
function countdown() {
time--;
if (time == 0) {
text = 'Erledigt';
} else {
hour=Math.floor(time/(60*60));
rest=time%(60*60);
min=Math.floor(rest/60);
rest=rest%60;
text = hour + ":" + min + ":" + rest;
window.setTimeout('countdown()', 1000);
}
document.getElementById('time_div').firstChild.data = text;
}
</script>
{/literal}
{/section}
|
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|