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

  • SEARCH
  • Home
  • 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 672101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:26:50+00:00 2026-05-14T00:26:50+00:00

It only works once. At second button click, nothing occurs. If I change budilnik

  • 0

It only works once. At second button click, nothing occurs.

If I change budilnik variable at i_budilnik or var budilnik, it doesn’t work even once!

Where is the problem?

<div>
<form name="alert">
    <input type="text" name="hour" />
    <input type="text" name="min" />
    <input type="button" value="ok" onclick="budilnik(this.form)">
</form><font color=#660000 size=20 face=Tahoma><span id="hours"></span>
</div>

<script type="text/javascript">


function budilnik(form) {
  budilnik = 1;
  min = form.min.value;
  hour = form.hour.value;
}

obj_hours = document.getElementById("hours");

function wr_hours() {
  time = new Date();

  time_min = time.getMinutes();
  time_hours = time.getHours();
  time_wr = ((time_hours < 10) ? "0" : "") + time_hours;
  time_wr += ":";
  time_wr += ((time_min < 10) ? "0" : "") + time_min;

  time_wr = time_wr;

  obj_hours.innerHTML = time_wr;

  if (i_budilnik == 1) {

      if (min == time_min) {
          if (hour == time_hours) {
              alert('welldone');
              budilnik = 0;
          }
      }
  }
}
wr_hours();
setInterval("wr_hours();", 1000);
</script>
  • 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-14T00:26:50+00:00Added an answer on May 14, 2026 at 12:26 am

    You call the function wr_hours(); only once… with the onclick budilnik is called, but that doesn’t touch wr_hours again. The first time the code is run, because the page is loaded, but after that, with the onclick only the values of min and hour are set again.

    edit: you shouldn’t call your form “alert”, since that’s a reserved word in javascript, same for the variable min. also: the variables min and hour are defined in the function budilnik, but they’re not known outside this scope. I also renamed the variable budilnik to a global variable justonce to make sure you can check it outside the scope of budilnik. I rewrote your code a bit:

    <html>
    <body>
        <div>
            <form name="frm">
                <input type="text" name="hour" />
                <input type="text" name="mins"/>
                <input type="button" value="ok" onclick="justonce=1;">
            </form>
            <font color=#660000 size=20 face=Tahoma><span id="hours"></span></font>
        </div>
    </body>
    </html>
    
    <script type="text/javascript">
    obj_hours=document.getElementById("hours");
    justonce=0;
    
    function wr_hours()
    {
        time=new Date();
    
        time_min=time.getMinutes();
        time_hours=time.getHours();
    
        time_wr=((time_hours<10)?"0":"")+time_hours;
        time_wr+=":";
        time_wr+=((time_min<10)?"0":"")+time_min;
    
        obj_hours.innerHTML=time_wr;
    
        if (justonce==1 && frm.mins.value==time_min && frm.hour.value==time_hours) {
                alert('welldone');
                justonce=0;
        }
    }
    
    setInterval("wr_hours();",1000);
    </script>
    

    Your function wr_hours could be a lot shorter by the way:

    function wr_hours()
    {
        time=new Date();
    
        obj_hours.innerHTML=("%02d",time.getHours())+":"+("%02d",time.getMinutes());
    
        if (justonce==1
            && frm.mins.value==time.getMinutes()
            && frm.hour.value==time.getHours()) {
            alert('welldone');
                justonce=0;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a timer object that works like a stop watch (click once and
I have an application widget that contains a button. Once I click the button,
I have code that works but only once. I need an input char a
The datepicker function only works on the first input box that is created. I'm
The tabexpansion function only works partially when I override it like so: function tabexpansion
I tried but I guess Message Box only works with win forms. What is
I just found out that lazy loading in Entity Framework only works from the
See code below, for some reason it only works when I put a breakpoint
I have tried : c(module_name). : but this only works from the shell, and
When using DataSources in ASP.net applications, paging and sorting along with GridView only works

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.