Hi, I am building a chat/messenger application using PHP and Javascript.
I currently have two iframes, one has the chat, the other the users in the database and their status, which is set to default ‘offline’ and updated to ‘online’ when logging in.There is also an option to change colour of both iframes like so:
function change_background_pink() { document.frames.chatContents.document.body.style.backgroundColor="pink";
and then this code to call the function:
<BUTTON onclick=change_background_pink()>Pink</BUTTON>
The problem is, that when the frames refresh, the background of the users frame goes back to the default white colour (the text does change to show newly logged users), yet the chat one stays the newly selected colour as intended (again the text changes as required).
Here is the code of the iframe as it stands now:
<?php
include("connect.php");
$query=mysql_query("SELECT * FROM users;");
echo "<table style='font-family:arial;font-size:14px;'>";
//
echo "<th align=left>Username:" . "<th align=left>Status:";
//while loop for rows
while($rows=mysql_fetch_array($query)){
echo "<tr>";
//show member deatils
echo "<td>" . $rows['username'] . "</td>" . "<td>" . $rows['status'] . "</td>";
echo "</tr>";
}
?><script type="text/javascript"><!--
setTimeout("refreshiframe()", 10000); //poll server
function refreshiframe(){
document.location.reload();
} //-->
</script>
What I am asking is if anybody knows how i can just refresh the actual text part of the frame from the database rather than the entire frame?
Many, many thanks in advance for any advice i may recieve and sorry if it sounds confusing i cannot think of a simpler way of explaining it.