Javascript problem with a function value returning:basic

Posted on 2003-03-11
Medium Priority
Last Modified: 2010-05-18
I  am new to Javascript, could anyone please help me on this.
This is very important for the project I am doing.

I have to submit a form after a certain time.
I use cookies to avoid time going back to initial stages,in case user refreshes the page.

If the user refreshes,
I am able to retrieve the time value from the cookie also, but I am not able to make the countdown run again..

I would really appreciate any help on this.

Below is the code, and its an ASP page.

<meta name="GENERATOR" Content="Microsoft Visual Studio.NET 7.0">

<script language=javascript>
function setCookiez(name, value)
     document.cookie = name + "=" +escape(value);

          var interval = "";
          var iter = 150;
          function startInterval()

               interval = window.setInterval("tTimer()",1000);

          function stopInterval()
              window.clearInterval (interval);
          function tTimer()
                   document.f.display.value = iter--;

                   if(iter % 10==0)

                    alert("You have 50 seconds left");

                  if (iter == -1)
                  alert ("Your Test Ends");

function readCookie()


    var the_cookie = document.cookie;

    var name = unescape(the_cookie);

    var broken_cookie = the_cookie.split("=");
//i split the cookie, here to get the time left
    var name = broken_cookie[2];
          alert("Value of iter is: "+iter);


<body onload="readCookie()" >

     Here we go!!
                         <form name="f" ID="Form2">
                              <input type="text" name="display" value="" ID="Text2">
                         <script language="javascript">

     <script language=javascript>
          document.writeln("here are cookies: "+document.cookie + "<br>");

<script language=javascript>
Question by:heartguy123
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

thomasdodds earned 105 total points
ID: 8112885
<body onload="readCookie();startInterval();" >

should reset your interval with every page load...

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question