This topic is locked
[SOLVED]

 Problems with Smartin in html

8/22/2009 3:55:11 PM
PHPRunner General questions
Pfeiffer author

Hello Support,

I'm still workong with 4.1.
I intend to show actual time/date in html code.

The following code in a htlml code (outside PHPRunner) works without problem..
Coding:

<html>

<head><script Language="JavaScript">

<!--

var TimeString, DateString;

function showTimeDate ()

{

Now = new Date();

Hours = Now.getHours();

Minutes = Now.getMinutes();

Seconds = Now.getSeconds();

TimeString = "" + Hours;

TimeString += ((Minutes < 10) ? ":0" : ":") + Minutes;

TimeString += ((Seconds < 10) ? ":0" : ":") + Seconds;

document.Ftime.inpTime.value = TimeString;

Day = Now.getDate();

Month = Now.getMonth()+1;

Year = Now.getYear();

DateString = "" + Day;

DateString += ((Month<10) ? ".0" : ".") + Month;

DateString += "." + Year;

document.Ftime.inpDate.value = DateString;

Timer = setTimeout("showTimeDate()", 1000);

}

// -->

</script>
<title>TimeDate</title>

</head>
<body onLoad="showTimeDate()">
<form name="Ftime">

<blockquote>

<pre>Zeit : <input type="text" name="inpTime" size="8" value></pre>

<pre>Datum : <input type="text" name="inpDate" size="8" value></pre>

</blockquote>

</form>

</body>

</html>
------------------------------------------------------------------------------------

I put this code to PHP-Runner HTML Page. There it looks the following :

Coding in PHPRunner HTML-Page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><script Language="JavaScript">

<!--

var TimeString, DateString;

function showTimeDate ()

{

Now = new Date();

Hours = Now.getHours();

Minutes = Now.getMinutes();

Seconds = Now.getSeconds();

TimeString = "" + Hours;

TimeString += ((Minutes < 10) ? ":0" : ":") + Minutes;

TimeString += ((Seconds < 10) ? ":0" : ":") + Seconds;

document.Ftime.inpTime.value = TimeString;

Day = Now.getDate();

Month = Now.getMonth()+1;

Year = Now.getYear();

DateString = "" + Day;

DateString += ((Month<10) ? ".0" : ".") + Month;

DateString += "." + Year;

document.Ftime.inpDate.value = DateString;

Timer = setTimeout("showTimeDate()", 1000);

}

// -->

</script>
<TITLE>Prüfung JETZT ablegen</TITLE>

<META http-equiv=Content-Type content="text/html; charset=windows-1252"><LINK

href="include/style{$sys_style}.css" type=text/css rel=stylesheet>

<META content="MSHTML 6.00.6000.16762" name=GENERATOR></HEAD>
<BODY onLoad="showTimeDate()" bgColor=white background="{$sys_wallpaper}" topMargin=5 {$onload}>{$includes}{include_if_exists file="include/header.php"}

<form name="Ftime">

<blockquote>

<pre>Zeit : <input type="text" name="inpTime" size="8" value></pre>

<pre>Datum : <input type="text" name="inpDate" size="8" value></pre>

</blockquote>

</form>

<FORM name=frmSearch action=schueler_zp_fragen_list.php method=get><input type="Hidden" name="a" value="search"><input type="Hidden" name="value" value="1"><input type="Hidden" name="SearchFor" value=""><input type="Hidden" name="SearchOption" value=""><input type="Hidden" name="SearchField" value=""></FORM>{include file="$showmasterfile"}

<TABLE>

<TBODY>

<TR>
.... and so on.
-------------------------------------------------------------------------------------

But it does'nt work because of an smarty error
Fehlertyp 256

Fehlerbeschreibung Smarty error: [in schueler_zp_fragen_list.htm line 6]: syntax error: unrecognized tag 'Now' (Smarty_Compiler.class5.php, line 580)

URL 213.174.33.163/PHPR 4.1 (317) Schuelerportal/schueler_zp_fragen_list.php?mastertable=schueler%5Fzp&masterkey1=27721

Fehlerdatei C:\Program Files\PHPRunner 4.1(317)\projects\PHP-ATM-Schüler\output\libs\Smarty.class5.php

Fehlerzeile 1095
Line 6 is :

Now = new Date();
what I'm doing wrong ??
Best regards

Uwe Pfeiffer

J
Jane 8/24/2009

Hi,
all JavaScript code should be inside {LITERAL} and {/LITERAL} tags.