All times are UTC - 6 hours   |  Page 1 of 1

Dion Designs

Can I call a js function of an external js source inside echo of php ???

Can I call a js function of an external js source inside echo of php ???

Posted: July 16th 2013, 4:14am
by docco
I have a js file name js_source.js with the function textDisplay() in it.
How can I call this fuction by echo of php?
I try
Code: Select all
<?php
echo "<script src='script/js_source.js'>textDisplay();</script>";
?>

It doesn't work

Can I call a js function of an external js source inside echo of php ???

Posted: July 16th 2013, 10:20am
by Dion
You can't place code inside a <script> tag that defines an external script. You'll need something like this:

Code: Select all
<?php
echo '<script type="text/javascript" src="script/js_source.js"></script><script type="text/javascript">textDisplay();</script>';
?>

Can I call a js function of an external js source inside echo of php ???

Posted: July 16th 2013, 10:28pm
by docco
Yes, separate the tag if careful, but not the key point.
After doing so, you can see it still dosen't work