Re: calling JS function from php
| From: | Mindaugas L | Date: | Thu, 25 May 2006 11:46:10 +0000 |
| Subject: | Re: calling JS function from php | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-236882@lists.php.net to get a copy of this message | ||
Hi,
print needs escaping, so fix style=\"\". Read XHTML requirements.
"<span style=padding-left:14.2cm><font size=2 face=Arial
color=#555555><script type=\"text/javascript\">";
I see you are missing semicolon when calling clientDate(); The same for
clientTime(); Javascripts need semicolons at the end of statement.
in the beginning style must be
On 5/25/06, Rabin Vincent <rabin@rab.in> wrote:
On 5/25/06, suresh kumar <asureshkumar_1983@yahoo.co.in> wrote: I am facing one problem in my project.I am trying to call a javascript function from php.but it not executing.this is my code. You can't "call" a javascript function from php. What you can do is output javascript code that calls a javascript function. function clientTime() {-- Mindaugasvar cNow = new Date(); var cHour = cNow.getHours(); var cMin = cNow.getMinutes(); var hour= cHour + ":" + cMin; return hour; } //End function clientTime function clientDate() { var cDate = new Date(); var clientYear = cDate.getFullYear(); var clientMonth = cDate.getMonth(); var clientDay = cDate.getDate(); var year= clientYear + "-" + clientMonth + "-" + clientDay; return year;} //End function clientDate <? print "<span style=padding-left:14.2cm><font size=2 face=Arial color=#555555><script type=\"text/javascript\">";print "clientTime()"; print "clientDate()</script></font></span>"; ?>Your functions are returning values, but you aren't printing out those values. Try: print "document.write(clientTime());"; Rabin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php