homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

echo back javascript problem

 7:07 pm on Oct 15, 2007 (gmt 0)

I'm trying to echo a javascript. I think I've commented out everything, but it's causing errors. Is there a better way to do this?

echo "<script type=\"text/javascript\" src=\"<a href=\"http://www.______.com/external.php?type=js\"></script>
<script language=\"\" type=\"text/javascript\">
for (var x in discussions)
document.writeln(\"<a href=\"http://www._______.com/showdiscussion.php?t=\"+discussion[x].discussionid+\"\">\"+discussion[x].title+\"</a> (Posted By: \"+discussion[x].poster+\")<br />\");



 7:24 pm on Oct 15, 2007 (gmt 0)

why not just break out of php?


 8:14 pm on Oct 15, 2007 (gmt 0)

Or at least use ' for your echo statement, so that you dont have to escape every " in the javascript. There did also seem to be some redundant tags in there...dont know if im just missing something, but in your first javascript block you dont need to have <a inside the src=. There did also seem to be some additional "s in there, but breaking out or at the least using ' would help to make the code easier to read and debug.


echo '<script type="text/javascript"
<script type="text/javascript">
for (var x in discussions)
<a href=\"http://www._______.com/showdiscussion.php?t="
"+discussion[x].title+"</a> (Posted By: "+discussion[x].poster+")
<br />");

I think I have put the correct " and ' in but test it to make sure.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved