View Full Version : how to call to a function(it is in javascript) from a php

03-13-2009, 01:53 AM
I'd like to ask how i can call a function which it is Javascript from php. Thanks

<script type="text/javascript">
function displaymessage()
alert("Hello World!");
if ($_SESSION['check']==1)
How i can call function displaymage()?????
echo "Bye";



03-13-2009, 02:11 AM
You cannot directly call a js function from php. php runs server-side while js runs client-side.

What you can do, is using your $_SESSION check, determine if the function should be called and, if so, echo the call to the function inside of the <body> tag (running it using the js on load event.

03-13-2009, 04:12 AM
Thanks for your helpping.

i will do like that
echo "<BODY onLoad="javascript:displaymessage();">"

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum