views:

33

answers:

3

I have this:

<a>
Stuff stuff stuff
<input type="Submit" onclick="....">
</a>

The problem is...when I click the submit button, it goes to the instead of onclick.

+2  A: 

Try this:

<input type="Button" onclick="....">

Use Button type instead of Submit :)

If you still want to use Submit, just place return false after your code eg:

<input type="Submit" onclick="doStuff(); return false;">
Sarfraz
Yes. The `<a>` (without href=) is irrelevant.
SF.
@SF: agreeeeed :)
Sarfraz
+1  A: 

Returning false from you on click handler should prevent the default behaviour, e.g.:

<a href="index.html">
  Stuff stuff stuff
  <input type="Submit" onclick="alert('test'); return false;">
</a>
Obalix
A: 

you can also make an <a> look like a button using CSS display: block or display: inline-block

Jeff Maes