JackWetson Posted February 18, 2010 Share Posted February 18, 2010 Hi Guys, Im trying to load the contents of an html file into a text area for editing, this is the code I have so far but it doesnt seem to be working. I think it's because some of the $line have "" etc in them which is messing it up, any help/advice is greatly appreciated. I've also commented out some things i've tried and didnt work! $handle = fopen("".$tmpfile, 'r'); $lines = file($tmpfile); echo '<form method="post" name="box" action="">'; echo '<textarea name="codebox"></textarea>'; echo '</form>'; foreach ($lines as $line_num => $line) { //$line = htmlentities($line,ENT_QUOTES); //echo $line; print("<script language = 'javascript'>alert(".''.$line.");</script>"); //Typical Line <html xmlns="http://www.w3.org/1999/xhtml"> // echo "<script language = 'javascript'>var newtext = "."'".$line."'"."; document.box.codebox.value += 'newtext'; </script>"; // echo "". htmlspecialchars($line) . "<br />\n"; } fclose($handle); Link to comment https://forums.phpfreaks.com/topic/192524-php-and-javascript/ Share on other sites More sharing options...
teamatomic Posted February 18, 2010 Share Posted February 18, 2010 print("<script language = 'javascript'>alert(".''.$line.");</script>");??????? Just echo out the line. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/192524-php-and-javascript/#findComment-1014367 Share on other sites More sharing options...
JackWetson Posted February 18, 2010 Author Share Posted February 18, 2010 print("<script language = 'javascript'>alert(".''.$line.");</script>");??????? Just echo out the line. HTH Teamatomic Just outputs "undefined" Link to comment https://forums.phpfreaks.com/topic/192524-php-and-javascript/#findComment-1014370 Share on other sites More sharing options...
teamatomic Posted February 18, 2010 Share Posted February 18, 2010 ahh. echo "$line"; Skip the javascript alert, its brain dead the way you are using it. also, skip the fopen/fclose, you get your array from file() HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/192524-php-and-javascript/#findComment-1014389 Share on other sites More sharing options...
JackWetson Posted February 18, 2010 Author Share Posted February 18, 2010 ahh. echo "$line"; Skip the javascript alert, its brain dead the way you are using it. also, skip the fopen/fclose, you get your array from file() HTH Teamatomic But i want to put the contents of $line into the text area so i can edit the contents, not just print it to the screen! Link to comment https://forums.phpfreaks.com/topic/192524-php-and-javascript/#findComment-1014414 Share on other sites More sharing options...
LeadingWebDev Posted February 18, 2010 Share Posted February 18, 2010 TeamAtomic said you how to check, why u disagree... if somebody say what to do about ur trouble do it and post result to continue resolving ur problem! Link to comment https://forums.phpfreaks.com/topic/192524-php-and-javascript/#findComment-1014464 Share on other sites More sharing options...
teamatomic Posted February 18, 2010 Share Posted February 18, 2010 Then put it inside the text area <textarea> foreach() { echo "$line" } </textarea> HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/192524-php-and-javascript/#findComment-1014468 Share on other sites More sharing options...
JackWetson Posted February 19, 2010 Author Share Posted February 19, 2010 TeamAtomic said you how to check, why u disagree... if somebody say what to do about ur trouble do it and post result to continue resolving ur problem! Because I had already tried that, that was why! Thank you for the fix, I was obviously just over-complicating the solution! Link to comment https://forums.phpfreaks.com/topic/192524-php-and-javascript/#findComment-1014736 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.