brian debottari (sin7) wrote:
I have a site that does the following:
You fill out a form with client info, click process, it moves to another
page that calls a few php functions i wrote (sending client welcome
email, adding client details to database and a few other things). What I
want the page to do is delay some of the content that gets displayed on
the php. the only way i've been able to do this is with a javascript
using setTimeout. I know this isn't a javascript list but here is my
javascript so you have a better idea what I'm trying to do:
--- start code ---
SCRIPT Language=Javascript type=text/javascript
!--
function timeout() {
setTimeout(replace(),2000);
setTimeout(replace2(),3000);
setTimeout(replace3(),5000);
setTimeout(replace4(),5500);
}
function replace() {
timed_text = document.getElementById(repl).firstChild.nodeValue;
document.getElementById(repl).firstChild.nodeValue=timed_text + Done.;
}
function replace2() {
timed_text2 = document.getElementById(repl2).firstChild.nodeValue;
document.getElementById(repl2).firstChild.nodeValue=timed_text2 +
Done.;
}
function replace3() {
timed_text3 = document.getElementById(repl3).firstChild.nodeValue;
document.getElementById(repl3).firstChild.nodeValue=timed_text3 +
Done.;
}
function replace4() {
timed_text4 = document.getElementById(repl4).firstChild.nodeValue;
document.getElementById(repl4).firstChild.nodeValue=Complete.;
}
//--
/SCRIPT
/HEAD
BODY onLOAD=timeout()
DIV id=replAdding client to database... /DIV
DIV id=repl2Configuring clients account... /DIV
DIV id=repl3Sending client welcome letter... /DIV
DIV id=repl4nbsp;/DIV
--- end code ---
I know this method is horid and the code is ya. But I'm just trying
to see if i can do it before i work really hard on it, then I'll fix the
code, so please don't make comments regarding the crappy code.
Anyhow, as you can see, I want the page to display Adding client to
database... then wait a few seconds while the php script runs the
function 'fnc_addClient', after it's done io want the page to display
Done so it would show:
Adding client to database Done
Any ideas how I can get this done with php? I've attempted the sleep()
with flush() but none of that is working.
either you use an 'ajax' technique (_maybe_ a little bit more than you
can chew right now.)
OR you just do something a bit like:
?php
include 'your/global/inc/file.php';
function get_fnc_res($bval) { return $bval ? 'Done' : 'Failed' }
// do security checks, etc, whatever
$r1 = fnc_addClient();
$r2 = $r1 fnc_confClient();
$r3 = $r2 fnc_welcomeClient();
echo '
div id=replAdding client to database... ',get_fnc_res($r1),'/div
div id=repl2Configuring clients account... ',get_fnc_res($r2),'/div
div id=repl3Sending client welcome letter... ',get_fnc_res($r3),'/div
div id=repl4nbsp;/div
';
?
dont bother to show something in the browser that is fake
(i.e. by the time the timeout() function runs in the browser the
php functions have long done there work - in fact it's quite possible
the sent email is received before the page is fully downloaded.)
Brian deBottari
Web Developer and System Administrator
sin7 Studios / sin7networks.us
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php