function timeout(x){ document.getElementById(x).innerHTML="processing"; setTimeout(document.getElementById(x).innerHTML="done",5000); } Code (markup): I've written this function, it should work fine, but there's a small problem, the setTimeout goes instantly. Instead of showing processing then after 5 seconds to show done, it directly displays done. Anyone knows how to fix this kind of problem?
not tested but... var beingDone, doneMessage = function(), { beingDone.innerHTML = 'done'; }, timeout = function(x) { beingDone = document.getElementById(x); beingDone.innerHTML = "processing"; setTimeout(doneMessage, 5000); }; timeout("mydiv"); // call it. PHP: you _should_ also be able to modify what you wrote in a way that works by using " " around code that it needs to evaluate but escaped it well for strings slashes etc.
function timeout(x) { document.getElementById(x).innerHTML = "processing"; setTimeout(function(){ document.getElementById(x).innerHTML = "done"; }, 5000); } Code (markup):