views:

27

answers:

2

How do I disable element so it will not submit when clicking on it (but make sure javascript events still work)? "Disabled" attribute turns javascript off.

+1  A: 

Add return false; to the Javascript event handler.
(or e.preventDefault(); e.returnValue = false;)

SLaks
I did this but there was no effect.
Aliens
Oh it works now. The only thing I needed to figure out myself was place a word return before the javascript function name in html attribute onClick.
Aliens
+1  A: 

Another option is to not make it a submit button

<input type="button" value="Button Text" onclick="myHandler()" />
Seattle Leonard
The problem is my element is <IMG> and not a button.
Aliens