View Full Version : Problem handling onclick event from a "reset" button

12-18-2003, 10:28 PM
Changed my mind, I will try to do better in the future. Didn't mean to offend anyone.

Here is the actual code that I have:

<input class="formbutton" type="reset" value="Clear" onclick="if(confirm('Stop Timer?'))stopTimer();" name=Stop

So, now... when I click on the button, it confirms to reset the timer. If I click cancel, it resets the form anyways. If I change the type to button, it doesn't clear the form at all. if I put in return false, still deletes the form if I click on the cancel button.

Any suggestions would be appreciated :)

12-18-2003, 11:22 PM
I suggest you read our posting guidelines (http://www.codingforums.com/postguide.htm) - particularly the bit about choosing an appropriate subject for your question.

Yours was particuarly innapropriate, because not only did you not describe the problem, you used a cheap psychological tactic to try to get people to look at it, and that's not fair.

So that's why I changed it.

12-19-2003, 12:27 AM
Don't feel bad everyone messes up somtimes-

You are trying to call other conditional events inside the reset that have nothing to do with whether or not it resets. Change it to a button and then if confirm = true have it click the reset button --> resetButtonId.click() (make the reset button have no display) along with what it is currently doing.

Hope that helps,

12-19-2003, 02:18 AM
<input class="formbutton" type="reset" value="Clear" onclick="if(confirm('Stop Timer?'))stopTimer();else return false;" name="Stop" ...>

The return false on onclick event handler cancels the action of the "reset" button

12-19-2003, 03:09 AM
Thanks that worked. :)