button in the form cause it be submitted automatically
Posted
by Spiderman
on Stack Overflow
See other posts from Stack Overflow
or by Spiderman
Published on 2010-03-13T21:11:16Z
Indexed on
2010/03/13
21:15 UTC
Read the original article
Hit count: 261
html
|JavaScript
has the HTML version changed lately (like from ie7 to IE8?) I notice the following change that cause me some troulbe - I am having a code that is similar to this:
<form method="POST" action="/admin/modify">
<input type="text"/>
<button onclick="dosomething()">Press</button>
</form>
<script type="text/javascript">
function doSomething(){
// doesn't matter what actually
}
</script>
What is weired to me in this code is that by pressing the button inside the form, all I want is to perform some javascript action but eventaully it causes the form to be submitted too, even when I am not willing to do it.
So - is it true? and if so how can I perform some java script actoin inside a from but prevent the form from being submitted automatically?
© Stack Overflow or respective owner