Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to call to a function(it is in javascript) from a php

Status
Not open for further replies.

xbl12

Programmer
Dec 12, 2006
66
Hi;
I'd like to ask how i can call a function which it is Javascript from php. Thanks


Code:
<?php
session_start();
$_SESSION['check']=1;
?>
<html>
<head>
<script type="text/javascript">
function displaymessage()
{
alert("Hello World!");
}
</script>
</head><body>
<?php
  if ($_SESSION['check']==1)
     How i can call function displaymage()?????
  else
     echo "Bye";
   
?>

</body>
</html>
 
Thanks for you come here, i got the solution already.

echo "<BODY onLoad="javascript:displaymessage();">
 
that's not going to work. You can't have double quotes within double quotes.

and that will only work, if you don't have another body tag already there, and you want to display the message at times other than when the page loads.

I believe what you want would be:

Code:
echo "<script>displaymessage();</script>";




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top