janu
February 2, 2008, 4:09pm
1
Hi, what I want is to execute some javascript code with echo(); basicallly see below what I want
echo "<script>javascript: alert('test msgbox')></script>";
the above code doesnt work, how to evaluate javascript code in echo() ?
please help…
thanks
janu
February 2, 2008, 4:16pm
2
I also tried the script type…
<script type=“text/javascript”>
but it does not execure my javascript functions…
You’re trying to use javascript like you would through the URL bar.
Remove the ‘javascript:’:
<?php
echo '<script type="text/javascript">alert("hello!");</script>';
?>
1 Like
janu
February 2, 2008, 8:14pm
4
thanks, it worked, honestly I tried this earlier, but that didnt work the only difference was that I was trying in double questions with \" but its working in single quotes. thanks
Cups
February 2, 2008, 10:30pm
5
Save yourself some future headaches when writing JS inside PHP, look at using the PHP heredoc syntax when possible.