Reputation: 127
<form id="activateform" method="post" action="/admin/changeStatusUser">
<input type="text" hidden="" value="7" name="userId"></input>
<a class="icon-5 info-tooltip" title="Activate" href="" onclick="document.getElementById('activateform').submit()"></a>
</form>
Here's my form that I need to submit when clicking the link(Can't use the button because the link has the style already defined). However, it's not working, on click it refreshes the page. However, if I change the anchor to input, everything works... so what am I doing wrong with my anchor?
Upvotes: 1
Views: 114
Reputation: 533
As others said, change href to #
or, another way is to add return false;
to onclick handler:
<a class="icon-5 info-tooltip" title="Activate" href="" onclick="document.getElementById('activateform').submit();return false;"></a>
Upvotes: 3
Reputation: 8371
Change href attribute to # Ex.
<a class="icon-5 info-tooltip" title="Activate" href="#" onclick="document.getElementById('activateform').submit()"></a>
or change it to javascript: Ex.
<a class="icon-5 info-tooltip" title="Activate" href="javascript:" onclick="document.getElementById('activateform').submit()"></a>
Upvotes: 0