Refresh Page - Unless Condition

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lucanos@gmail.com

    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

  • Jedi Fans

    #2
    Re: Refresh Page - Unless Condition

    lucanos@gmail.c om 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.setTimeo ut("refreshWind ow()",100000);

    Comment

    • lucanos@gmail.com

      #3
      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)

      Comment

      • Jedi Fans

        #4
        Re: Refresh Page - Unless Condition

        lucanos@gmail.c om 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.setInter val instead of window.setTimeo ut

        Comment

        • lucanos@gmail.com

          #5
          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

          Comment

          • Jedi Fans

            #6
            Re: Refresh Page - Unless Condition

            lucanos@gmail.c om 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

            Comment

            Working...