Hello:
I was wondering if any of you guys know a way to display a clock in the header of a grid, i’ve tried with jscript unsucessfuly and i got blocked lol any ideas?.
Regards
Hello:
I was wondering if any of you guys know a way to display a clock in the header of a grid, i’ve tried with jscript unsucessfuly and i got blocked lol any ideas?.
Regards
[QUOTE=kafecadm;35364]Hello:
I was wondering if any of you guys know a way to display a clock in the header of a grid, i’ve tried with jscript unsucessfuly and i got blocked lol any ideas?.
Regards[/QUOTE]
What code you tried and how?
I remember that MikeDE posted some code for that, should be searchable here on the forum.
The following code was published here as a count down, but should be convertable for showing the current time. It’s put in the header (layout->htmltemplates).
<script type = "text/javascript">
/*author Philip M. 2010*/
var timeInSecs;
var ticker;
function startTimer(secs)
{
timeInSecs = parseInt(secs)-1;
ticker = setInterval("tick()",1000); // every second
}
function tick()
{
var secs = timeInSecs;
if (secs>0)
{
timeInSecs--;
}
else
{
clearInterval(ticker); // stop counting at zero
// startTimer(60); // remove forward slashes in front of startTimer to repeat if required
}
document.getElementById("countdown").innerHTML = 'Next refresh in '+secs+' seconds!';
}
//startTimer(60); // 60 seconds
</script>
<style>
#lin1_col1 { padding-left:9px; padding-top:7px; height:27px; overflow:hidden; text-align:left;}
#lin1_col2 { padding-right:9px; padding-top:7px; height:27px; text-align:right; overflow:hidden; font-size:12px; font-weight:normal;}
</style>
<div style="width: 100%">
<div {NM_CSS_FUN_CAB} style="height:11px; display: block; border-width:0px; "></div>
<div style="height:37px; border-width:0px 0px 1px 0px; border-style: dashed; border-color:#ddd; display: block">
<table style="width:100%; border-collapse:collapse; padding:0;">
<tr>
<td id="lin1_col1" {NM_CSS_CAB}><span id="countdown" style="font-weight: bold; color: red">Next refresh in 60 seconds</span></td>
<td id="lin1_col2" {NM_CSS_CAB}><span>{LIN1_COL2}</span></td>
</tr>
</table>
</div>
</div>
<script>startTimer(60);</script>
Thank you so much guys, I’ve tried something similar my problem was on calling the js function… no mather what i get an error stating “undfined fuction”
this is the code im using:
onApplicationInit
echo '
<script type="text/javascript">
function display_c(){
var refresh=100; // Refresh rate in milli seconds
mytime=setTimeout(\'display_ct()\',refresh)
}
function display_ct() {
var strcount
var x = new Date()
document.getElementsByName(\'ct\').innerHTML = x;
tt=display_c();
}
display_ct();
</script>
';
then in the header I’m using something like
<span name=“ct”></span>
so the html contect gets modified and updates the clock
ok guys I figured it out… in the onapplicationinit i created a global variable
[g_Clock] = '<p id="demo"></p>
<script>
function clock(){
var d = new Date();
document.getElementById("demo").innerHTML = d.toString();
}
setInterval(clock,100);
</script>
';
=D
bingo :)))))
sempai
after bingo, any indication how to change and play with the format? also it shows +5GMT… i want to customize this along with addming some html colors stuff