Jump to content

PHP and Javascript


JackWetson

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.