Solution: Javascript with PHP
I know that a lot of people come here looking for answers. Here's one I couldn't find a solution to on the forum:
Question :
How do I insert javascript in php code?
Answer :
You just echo / print the javascript like you would do with html, like:
<?
echo "<script language=\"JavaScript\">\n";
echo "alert("javascript from php");\n";
echo "</script>";
?>
CPRhosting.com - CPR Hosting...Giving life to the web
Custom-made Hosting Plans starting at $2
arin posted this at 04:06 — 21st May 2002.
They have: 8 posts
Joined: May 2002
The other way is just as fun -- getting PHP outputs to come up in JScript:
<script language="JScript">
window.alert( "You have this much 1337ness: " + <?php echo $result; ?> );
</script>
Just make sure it's in a file that's parseable by PHP (.php/.php3/.phtml etc).
arin
[edit]: I can't spell 1337ness
Web hosting from just $2 a month! http://www.xeosdd.net
Mark Hensler posted this at 06:53 — 21st May 2002.
He has: 4,048 posts
Joined: Aug 2000
1337|\|355
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.