Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  24] [ 7]  / answers: 1 / hits: 23789  / 11 Years ago, fri, february 22, 2013, 12:00:00

Here is my code



        <form class=form-horizontal>

<div class=control-group>
<div class=controls>
<button onclick=javascript:add_user_group(2); class=btn>add</button>
</div>
</div>

<table id=users-table class=table table-striped >
<thead>
<tr>
<th>User Name</th>
<th>Delete</th>
</tr>
</thead>
<tbody>

</tbody>
</table>

</form>


I just want to add a new row to a table when a add button clicked, but it seems a click of the add button triggers a submission of form.



Isn't is only a button with



 type=submit


to submit form. Or any button in a form triggers a submission of form ?


More From » html

 Answers
47

Having false returned in the function called onclick will prevent form submission. :)



onclick=javascript:add_user_group(2);return false;

[#80060] Thursday, February 21, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
donovanjasek

Total Points: 465
Total Questions: 103
Total Answers: 113

Location: Saint Vincent and the Grenadines
Member since Thu, Oct 15, 2020
4 Years ago
;