| echo back javascript problem
|
matthewamzn

msg:3478141 | 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 />\"); } //--> </script>";
|
jatar_k

msg:3478163 | 7:24 pm on Oct 15, 2007 (gmt 0) | why not just break out of php?
|
PHP_Chimp

msg:3478191 | 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. Try echo '<script type="text/javascript" src="http://www.______.com/external.php?type=js"> </script> <script 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 />"); } //--> </script>'; I think I have put the correct " and ' in but test it to make sure.
|
|
|