I have a form with two buttons. The bottom one should submit the form to the server. In the middle of the form there is another button that needs to trigger a simple scoring function and add this score value in a new form field (which will or won’t be submitted depending on its existence).
Using the Prototype js library, how would I cancel this middle button from submitting the form and have it perform my calculation/DOM addition function?
EDIT:
What I have currently isn’t preventing the form submit…
$$('.form-submit-calculate').each(function(calculator){
calculator.observe("click",function(){alert('calculate'); return false; });
});
for
<div id="cid_31" class="form-input-wide">
<div style="margin-left:406px" class="form-buttons-wrapper">
<button id="input_31" class="form-submit-calculate">
Get Score
</button>
</div>
</div>
1 Answer