Connecting Tech Pros Worldwide Help | Site Map

Refresh Page - Unless Condition

lucanos@gmail.com
Guest
 
Posts: n/a
#1: Jul 26 '05
Hey Guys,

Hoping that you can help me, as I have been scratching my head and
getting nothing but dandruff...

SITUATION
---------
I have a webpage which users will be viewing, which has forms which can
be hidden or displayed at the user's choice. The problem is that they
want the page to refresh every X seconds, but if it refreshes when a
form is displayed, then the form loses the entered data and disappears
as the screen is redrawn, meaning the user has to write it all up
again.

MISSION
-------
I want to create a JavaScript refresh function, which will only refresh
the page if a certain condition is met. The condition will be a
variable which will count the number of forms currently being
displayed. If the variable ('openForms') is 0, then the refresh should
be executed.

ATTEMPTS THUSFAR
----------------
function refreshCounter() {
Id = setTimeout( refreshWindow() , 100000 );
}
function refreshWindow() {
if ( openForms==0 ) {
// No Windows Open - Reloading
window.location.reload(true);
} else {
// Windows Open - NO Reload
}
}

RESULT THUSFAR
--------------
The page was constantly trying to reload the second it opened - causing
a loop which only stopped when I commented out the second line of
"refreshCounter()".

Any suggestions, or assistance would be appreciated.
Am I doing this the easiest possible way? Or is there a better option?

Thanks
Luke

Jedi Fans
Guest
 
Posts: n/a
#2: Jul 26 '05

re: Refresh Page - Unless Condition


lucanos@gmail.com wrote:[color=blue]
> Hey Guys,
>
> Hoping that you can help me, as I have been scratching my head and
> getting nothing but dandruff...
>
> SITUATION
> ---------
> I have a webpage which users will be viewing, which has forms which can
> be hidden or displayed at the user's choice. The problem is that they
> want the page to refresh every X seconds, but if it refreshes when a
> form is displayed, then the form loses the entered data and disappears
> as the screen is redrawn, meaning the user has to write it all up
> again.
>
> MISSION
> -------
> I want to create a JavaScript refresh function, which will only refresh
> the page if a certain condition is met. The condition will be a
> variable which will count the number of forms currently being
> displayed. If the variable ('openForms') is 0, then the refresh should
> be executed.
>
> ATTEMPTS THUSFAR
> ----------------
> function refreshCounter() {
> Id = setTimeout( refreshWindow() , 100000 );
> }[/color]
<SNIP>
Id = setTimeout( refreshWindow() , 100000 );
should be
window.setTimeout("refreshWindow()",100000);
lucanos@gmail.com
Guest
 
Posts: n/a
#3: Jul 26 '05

re: Refresh Page - Unless Condition


Hi "Jedi Fans",

Thanks for your lightning quick response!!!!

Such a simple error and a messy result...
I have made the modification as suggested and, for the first run
through, it worked - I had a form open (so the condition would prevent
the refresh from happening) for the first cycle, and then I hid it (so
the condition would let the refresh happen) the second time, but it
looked like the loop ceased after the first run.

Any further suggestions on how I can achieve this?

Thanks
Luke
(Apprentice)

Jedi Fans
Guest
 
Posts: n/a
#4: Jul 26 '05

re: Refresh Page - Unless Condition


lucanos@gmail.com wrote:[color=blue]
> Hi "Jedi Fans",
>
> Thanks for your lightning quick response!!!!
>
> Such a simple error and a messy result...
> I have made the modification as suggested and, for the first run
> through, it worked - I had a form open (so the condition would prevent
> the refresh from happening) for the first cycle, and then I hid it (so
> the condition would let the refresh happen) the second time, but it
> looked like the loop ceased after the first run.
>
> Any further suggestions on how I can achieve this?
>
> Thanks
> Luke
> (Apprentice)
>[/color]
window.setInterval instead of window.setTimeout
lucanos@gmail.com
Guest
 
Posts: n/a
#5: Jul 26 '05

re: Refresh Page - Unless Condition


Hey Jedi Fan,

You're a scholar & a saint!

Thanks for your help (Man, I feel like a newbie...)
Luke

Jedi Fans
Guest
 
Posts: n/a
#6: Jul 26 '05

re: Refresh Page - Unless Condition


lucanos@gmail.com wrote:[color=blue]
> Hey Jedi Fan,
>
> You're a scholar & a saint!
>
> Thanks for your help (Man, I feel like a newbie...)
> Luke
>[/color]
yvw Luke, also unless your email address doesnt mind being spammed...
best to munge it like this:
lucanos[at]gmailNOSPAM[dot]com or summin invalid so the spammers dont get it
Closed Thread