Code to refresh table and not entire web page

They have: 4 posts

Joined: Feb 2009

I would like to know and am very interested/ have the need to be able to create a button or something that when clicked refreshes a table
and the contents inside the table without refreshing the whole page so that an image or anything in the table can be refreshed instead of reloading the entire page.

Is this possible?

I have seen javascript buttons that refresh the page but not this feature that i am interested in in only refreshing parts of a page (table).

decibel.places's picture

He has: 1,494 posts

Joined: Jun 2008

They have: 4 posts

Joined: Feb 2009

Does any one have code they could supply that does this that can be just copied and pasted in. Something like this:

function refreshpage()
{
window.location.reload();
}

(except this refreshes the whole page)

decibel.places's picture

He has: 1,494 posts

Joined: Jun 2008

daltonsurf wrote:
Does any one have code they could supply that does this that can be just copied and pasted in.

This cannot be done because it depends on your code - what id you choose to name the table etc.

If you can post your code for the table (enclose the code in the code tags 3rd icon from the right in the toolbar) we might be able to better help you.

They have: 4 posts

Joined: Feb 2009

Well it would be something like this with a button somewhere to refresh the table only.

Picture.jpg
Refresh

They have: 4 posts

Joined: Feb 2009

Sorry the code didnt show up in the last post lets see if it does now

<table border="0">
<tr>
<td>Picture.jpg</td>
<td>refresh</td>
</tr>
</table>

decibel.places's picture

He has: 1,494 posts

Joined: Jun 2008

try this (see attached)

<table border="0">
<tr>
<td id="imagecell"><img src="http://www.webmaster-forums.net/ads_customimages/host4u_120x60.gif"></td>
<td><a href="javascript:void(0);" onclick="document.getElementById('imagecell').innerHTML='<img src=\'http://www.webmaster-forums.net/files/pictures/picture-1018260.png\'>';">refresh</a></td>
</tr>
</table>

it would actually be simpler to swap the src of the image, but this method will allow you to change the entire HTML content for the table cell, if you need to add text etc.

if you are doing this a few times, or the innerHTML replacement is more complex, I would recommend creating a javascript function that can accept various tokens.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.