Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4539100
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:54:00+00:00 2026-05-21T14:54:00+00:00

My code as follow: <html xmlns=http://www.w3.org/1999/xhtml> <head> <meta http-equiv=content-type content=text/html; charset=UTF-8> <title>Demo</title> <style type=text/css>

  • 0

My code as follow:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Demo</title>  
 <style type="text/css">
    #submitbox .button{
        padding:3px 6px;
        background:#B4D666;
        border-top:1px solid #B4D666;
        border-right:1px solid #81B840;
        border-bottom:1px solid #81B840;
        border-left:1px solid #B4D666;
        color:#2970A6;
        font-size:11px;
        cursor:pointer;
    }

    #submitbox .disabled-button{
        background: #CCCCCC;
        border-color: #CCCCCC #999999;
        color: #CC6600;
    }    
</style>
</head>
<body>
    <form name="form1" method="post" action="#">

        <input name="counter" id="counter" value="enable" type="text" /> <br/><br/>
        <div id="submitbox">     
            <input id="cmt-submit" type="button" class="button" value="Submit comment" onclick="return timer();" />
        </div>

        <script type="text/javascript">
            <!-- 
            // 
            var cmtSubmit = document.getElementById('cmt-submit');
            var count = document.getElementById('counter');
            var milisec = 0;
            var seconds = 10;
            var timercmt = 0;
            var timertxt = 0;
            function display() {
                if (milisec <= 0) {
                    milisec = 9;
                    seconds -= 1;
                }
                if (seconds <= -1) {
                    milisec = 0;
                    seconds += 1;
                }
                if (seconds == 0) {
                    cmtSubmit.value = "Submit comment";
                    cmtSubmit.disabled=false;
                    cmtSubmit.className = "button";                  
                    clearTimeout(timercmt);                           
                }
                else {
                    milisec -= 1;
                    cmtSubmit.value = seconds + " sec wait before next comment";
                    cmtSubmit.disabled = true;
                    cmtSubmit.className = "disabled-button";                     
                    timercmt = setTimeout("display()", 100);
                }
            }

            function timer() {      
                if (count.value == "enable") { 
                    count.value = "disable";
                    timertxt = setTimeout("setCounter()", 10000);
                    return true;                              
                } 
                else      
                {        
                    clearTimeout(timertxt);   
                    display();    
                    count.value == "enable"           
                    return false; 
                }
            }  

            function setCounter() {
                count.value == "enable"    
            }  
            --> 
        </script>
    </form>
</body>
</html>

It only works on the first run time hix hix.

Can anyone see where I am going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T14:54:01+00:00Added an answer on May 21, 2026 at 2:54 pm

    Found it: You forgot to re-initialize variable. Updated code is as follows:

        <script type="text/javascript">
            <!-- 
            // 
            var cmtSubmit = document.getElementById('cmt-submit');
            var count = document.getElementById('counter');
            var milisec = 0;
            var seconds = 10;
            var timercmt = 0;
            var timertxt = 0;
            function display() {
                if (milisec <= 0) {
                    milisec = 9;
                    seconds -= 1;
                }
                if (seconds <= -1) {
                    milisec = 0;
                    seconds += 1;
                }
                if (seconds == 0) {
                    cmtSubmit.value = "Submit comment";
                    cmtSubmit.disabled = false;
                    cmtSubmit.className = "button";                  
                    clearTimeout(timercmt);   
                    //--- You have to re--initialize variables here
                     milisec = 0;
                     seconds = 10;
                     timercmt = 0;
                     timertxt = 0;                        
                }
                else {
                    milisec -= 1;
                    cmtSubmit.value = seconds + " sec wait before next comment";
                    cmtSubmit.disabled = true;
                    cmtSubmit.className = "disabled-button";                     
                    timercmt = setTimeout("display()", 100);
                }
            }
    
            function timer() {      
                if (count.value == "enable") { 
                    count.value = "disable";
                    timertxt = setTimeout("setCounter()", 10000);
                    return true;                              
                } 
                else      
                {        
                    clearTimeout(timertxt);   
                    display();    
                    count.value == "enable"           
                    return false; 
                }
            }  
    
            function setCounter() {
                count.value == "enable"    
            }  
            --> 
        </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let say I've this code : <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
Kindly look at the following code: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
I am trying to follow Trees tutorial at: http://cslibrary.stanford.edu/110/BinaryTrees.html Here is the code I
This has me stumped. The follow code returns ,,,,,,: <script type=text/javascript> $(function() { $('#listB').sortable({
I have follow html code: <a href=#>Evente (0)</a> an i need: <a href=#>Evente <span>0</span></a>
hey guys I have the follow code in js: $(document).ready(function(){ $(.replyLink).click(function(){ $(#form-to-+this.id).html(htmlForm()).toggle(500); return false;
My tool tip code is as follows: HTML/CSS a.tooltip span { display: none; padding:
i have the follow code: searchResults.SearchResultCollection.Add( new SearchResult() { Header = HttpUtility.HtmlDecode( htmlDocument.DocumentNode .SelectSingleNode(initialXPath
I'm trying to follow code-to-interface on a project. Should I be creating an interface
Hi i am having the follow code <div id=container> <div class=element NOTME></div> <div class=element></div>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.