Before I get into all the details...
Is it possible to dynamically build JAVA Script on a web page using PHP?
--Tim
[SOLVED] PHP and JAVA Script
Moderator: General Moderators
[SOLVED] PHP and JAVA Script
Last edited by tstimple on Tue Nov 02, 2004 5:49 am, edited 1 time in total.
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Building PHP is like assuming PHP is an "HTML editor", it just adds text to a "file", even if the "file" is really just memory. All you need to do is output the script as though it was HTML..
Very Simple Example:
Very Simple Example:
Code: Select all
<?php
echo('<html>
<head>
<title>Pointless test</title>
</head>
<body>
<script language="javascript">
function writeText(mytext)
{ document.write(mytext); }
</script>
<script language="javascript">alert("Hello World");</script>
<p> Well This is written by PHP </p>
<script language="javascript">
writeText("This is HTML written via javascript function");
<noscript>This dummy needs Javascript</noscript>
</body>
</html>');
?>