473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Refresh Page - Unless Condition

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

Jul 26 '05 #1
5 2496
lu*****@gmail.com wrote:
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 );
}

<SNIP>
Id = setTimeout( refreshWindow() , 100000 );
should be
window.setTimeout("refreshWindow()",100000);
Jul 26 '05 #2
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)

Jul 26 '05 #3
lu*****@gmail.com wrote:
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)

window.setInterval instead of window.setTimeout
Jul 26 '05 #4
Hey Jedi Fan,

You're a scholar & a saint!

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

Jul 26 '05 #5
lu*****@gmail.com wrote:
Hey Jedi Fan,

You're a scholar & a saint!

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

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
Jul 26 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Rick | last post by:
Hi folks, I have a web page I wrote for a class assignment (which I embellished a little) that doesn't seem to work on all browsers, platforms, etc. The problem appears to be that the page...
10
by: Conax | last post by:
Hi there, My boss is hoping that I can come up with a page that displays some information. The information will always be displayed on specific part of the page, with auto refresh. But he...
1
by: SPQR | last post by:
Some time ago I set up a webcam at home and a page on my site. Every three minutes the webcam would take a picture of my backyard and ftp it to my site where it was displayed on my webcam page. ...
2
by: Mike | last post by:
oh my pages i have an option to allow user to refresh and a text box for them to enter in 10, 20 , 4 and i break it down to seconds. but then the page actaully refreshs the data is not refreshing...
2
by: Just D. | last post by:
All, How should we refresh the current aspx frame? I disabled caching using this command on Page_Load(): Response.Cache.SetCacheability(HttpCacheability.NoCache); but it didn't help. The...
10
by: Fred Nelson | last post by:
Hi: I have a VB.NET web application and I need to find a way to cause a page refresh from within my application. Does anyone know how to force the browser to refresh the current page? ...
8
by: Jason S | last post by:
Hi, is there any way of getting my VB (6.0) program to automatically 'Refresh' an IE window that might be active (window status not applicable). It needs to be able to determine which active IE...
1
by: rockdale | last post by:
Hi, all I am coding a asp.net application as user data entry and report interface. We also have another C#.net appplication (a server) does some other stuff, my webserver can send and receive...
6
by: Chris Beall | last post by:
(I'm rather inexperienced with JavaScript; the failing page was cobbled together from multiple sources)... http://pages.prodigy.net/chris_beall/STL/Timeline.html If JavaScript is not present,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.