Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delaying page loading or sequence of events

Status
Not open for further replies.

JMay0816

Programmer
Mar 1, 2007
34
US
I am designing a web site which requires log in. After a person logs in, they are redirected to an information page. On this page, they will get a welcome message and then it will execute some php code to check for certain events:

Example:

Checking for pending requests...................DONE
Checking for overdue requests...................DONE

So...my question is....how do I make it to where the "." are displaying one at a time and then after the first line is checked, the second will kick off.

Does this make sense?

thx
 
You would have to do all that in php. The javascript in the code would have no idea at what point in the php code your are at. For an accurate adding of ... and the next lines of text, you will need to keep track within the code (php) you are running.

[monkey][snake] <.
 
how bout just starting out simple....

forget the PHP...I think I can handle that aspect differently. How about just creating the text as mentioned above?
 
There are many ways you can do this. You could, for example, have an empty string which you append a period to, then set the innerHTML of a span element:

Code:
var dots = '';

function updateDots() {
   dots += '.';
   document.getElementById('someSpanId').innerHTML = dots;
}

...

<p>Checking for overdue requests<span id="someSpanId"></span></p>

Obviously, you'd need to define your own 'done' requirements.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Assuming you just want to 'create the text', then you could have HTML on the page (the 'p' element in my example above), and call the JS every time you wanted to update the dots.

How you call the JS, and how often you call it would need to be decided by you (assuming you wanted the dots to accurately represent a percentage of the server-side work done).

If, however, you wanted to call the JS arbitrarily on a timer (just to give the impression of work in progress), then that's a different matter... but you'd need to let us know this is the case (if this is the case, a simple timer would do the job).

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
to keep it as simple as possible, let's just say I want it to display:

Checking for pending..........

with say 10 dots.

 
i was able to delay one dot...now i guess the trick is to loop it.
 
never mind...turns out it wasn't doing what i thought it was. back to square one.
 
how do you call the function at regular intervals without the use of an input button? I think this is where I am getting hung up.
 
Maybe you should explain what exactly you're trying to delay.... Do you want to show this info as the page is loading, or some other back end process is taking place? Is this for an ajax request? Is it some long running javascript function that you'd like to show notification that it's doing something until it's complete. What you're asking for could be applied to any of these 3 situations, yet you'd have to code all 3 situations differently.

Provide a bit more information than "I need to make the dots appear at intervals" otherwise we're just taking wild stabs in the dark.

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
uncle_rico_thumb.jpg
 
sry bout all that....i'll start from the begining.

when the page loads, i want to display the following:

Checking for pending requests............

the dots should appear one at a time in one second intervals


not tied to anything processing or what have you...just all for looks.
 
To call a function at one-second intervals, you can use this syntax:

Code:
var timerHandle = setInterval('funcName();', 1000);

To stop the timer, you would use:

Code:
clearInterval(timerHandle);

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top