Re: alert is not appearing
I got it to work.... by removing the form tag... which is what I expected... the presence of a form tag cause the browser to do a form send, either by GET (default) or POST ... so what's happening is that you're GETting the form, causing it to reload/refresh... so the timer never gets a chance to run.
-tg
Re: alert is not appearing
Quote:
Originally Posted by
techgnome
I got it to work.... by removing the form tag... which is what I expected... the presence of a form tag cause the browser to do a form send, either by GET (default) or POST ... so what's happening is that you're GETting the form, causing it to reload/refresh... so the timer never gets a chance to run.
-tg
Correct. If you want to use a button in a form tag, use <input type="button", not the button element. As using the button element can submit a form: http://www.w3schools.com/tags/tag_button.asp
Re: alert is not appearing
You can also just do <button type="button">click me</button> to prevent form submission with a button tag.
https://developer.mozilla.org/en-US/...Element/button
Re: alert is not appearing
I am wondering - can you also do it by having a RETURN FALSE somewhere in that function to stop the event from propagating? Just curious...
Re: alert is not appearing
if the myFunction returns False... then you would have to call it like this:
<button onclick="return myFunction();">Try it</button>
you could also do this (and not modify the myFunction):
<button onclick="myFunction(); return false;">Try it</button>
I've done that before... but it would also depend on whether the form was just a container for the button (and if that's the case it should be removed to be semantically right)
-tg