Hi all.
I would like to load a php variable with HTML markup that is stored in an external text file and then pass this markup to the innerHtml of a DIV element.
I have this code:
<?php
$textfile="textfile.txt";
$handle = fopen($textfile, "r");
$contents = fread($handle,filesize($textfile));
fclose($handle);
?>
div = document.getElementById('contentdiv');
div.innerHTML = '<?php print $contents; ?>';
This is not working.
I have tried with a plain text also, so I guess it has something to do
with the way the file is read into the variable.
I have tried hardcoding $content="Text" and it works as expected, so I know the markup is correct.
Can anyone help me out with this?
Thanks a lot for your time.



Reply With Quote


Bookmarks