When I click on the button, the first time, everything works fine, but the second time, nothing happens. Why is that?
Learn to use Firebug. It'll help you immensely in the future.
This may sound crazy, but this is redefining the function budilnik to an integer, which breaks your form's onlick. If you preface this statement with keyword
var , you will shadow the function but not overwrite it. When you do not specify the
var keyword, variables are assumed to be global scope, which can cause issues (like this).
I used firebug to see that on the second click, "budilnik is not defined." If you had used this tool, you could have probably debugged this issue yourself.
budilnik is shadowing the function
budilnik . Change the name of the variable, and your function should work right every time.
In more detail:
budilink defined as a function. When
budilnik is executed, the value of
budilink , it tries to execute 1, instead of the function that was there before.
var keyword before your variable name.
I've tested the following code and it just works: