<html> <h1>what is the time</h1> <script language="javascript" type="text/javascript"> var now=new Date(); var Mhour=now.getHour(); if (Mhour>12) { Mhour-=12; } var Mminute=now.getMinute(); if (Mminute.length==1) { Mminute="0" + Mminute; } document.write =(Mhour + ":" + Mminute); function MyHour() { if (Mhour<=9) document.writeln("you can still sleep") else if(Mhour<=17) document.writeln("you should work") else document.writeln("evening time") } </script> <body> <input type="button" value="press me" onclick="MyHour()"> </body> </html> hi everyone! I need your help- from some reason this script doesn't work - according to firebug in firefox it's becuase i didn't define a date but as we know the arg var now=new Date(); returns the date otomaticly, correct? so what is wrong with my function? Needs your help quickly Progfrog
var d = document; var b = d.body; function MyHour(){ var text; if (Mhour <= 9) text = 'you can still sleep'; else { if (Mhour <= 17) text = 'you should work'; else text = 'evening time'; } b.appendChild(d.createTextNode(text)); } PHP: Edited.