View Single Post
Old 10-21-2003, 12:10 PM   #9 (permalink)
Culland
Inactive
 
Join Date: 10-20-03
Posts: 21
iTrader: 0 / 0%
Latest Blog:
None

Culland is liked by many
I think I am still missing what you are asking then, as I am not sure why PHP being resolved on the server as a problem. Unless you are front loading all the HTML through javascript, which as you said is a heavy load to start if its big files, the client must go back to the server to reload the DIV, same as if it was going to reload the entire page, which means using PHP to read in HTML files is a viable use. I just tested what I earlier wrote and it works fine in a div (though I missed an echo before the function).

Here is the code for a PHP page. This is just using text and not reading in files, but it uses PHP and javascript to update the DIV block. You would need to make a gethtml function that fopen() and reads an html page to a string and returns that string which in turn is echo'd to the browser. It would work similiar to an iframe, other than its not a seperate frame so your HTML you are inserting wont have its own html, head, body tags, just the meat of the HTML.


[code:1:a55508ef2a]<?php
function gethtml($thenumber){
if($thenumber==1){
return "Testing One";
} else {
return "Testing Two";
}
}
?>

<html>
<head>
<script language="javascript">
function dostuff(){
x = document.getElementById("mainblock");
x.innerHTML = "<?php echo gethtml(2); ?>";

}
</script>
</head>
<body>
<div id="mainblock">
<?php echo gethtml(1); ?>
</div>
<br><br>
<input type="button" onClick="dostuff()" value="Push">
</body>
</html>[/code:1:a55508ef2a]
Culland is offline   Reply With Quote