Jump to content

Dynamically reading and displaying values


seth001

Recommended Posts

You can use JavaScript:

 

var updateInterval;

window.onload = function()
{
    updateInterval = setInterval(updateText, 60000) // once a minute
}

function updateText()
{
    var txt = // method of getting text
    document.getElementById('updateMe').innerHTML = txt;
}

 

The element that will contain the text needs defining:

 

<span id="updateMe">Update me...</span>

 

Populate the initial text normally to prevent users with JS disabled missing out.

 

You'll notice I haven't actually written the AJAX request; you're better off reading up on AJAX first and understanding what it is and how it works, before you start using it. However I've given you the basic structure for your code which should allow you do make a start... All you need to do is submit a HTTP request either to the flat file containing the text, or a PHP script that will return the text for you. There's a lot of online resources that should be able to help you with that part.

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.