...

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



jrmevans
12-18-2003, 11: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
style="color:#ffddee;cursor:hand;border-color:red;"
onmouseover="this.style.background='#990000'"
onmouseout="this.style.background='#000000'">

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 :)

brothercake
12-19-2003, 12:22 AM
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.

Basscyst
12-19-2003, 01: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,
Basscyst

glenngv
12-19-2003, 03: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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum