PHP scripts run on server side and results in combination of HTML codes to client machine resulting in a complete page that user can see. Javscript runs on client machine.
two ways out:
1. if you are using a .
js file(.
js file is the file extension that contains all javascript function), then you can include this .
js file using
<?
echo "<SCRIPT language=JavaScript src='script.
js' type='text/javascript'>";
?>
anywhere in the php code, either in body part or in header part of php file.
2. if you are not including a .
js file then:
you should write code like:
<?
echo "<SCRIPT language=JavaScript type='text/javascript'>\n";
//write javascript functions with echo command so that when php
//returns HTML code it look like simple javascript
echo "</SCRIPT>\n";
?>
i hope this clarifies.
regards,
-Jay