I can't find anything regarding this simple problem.
I'm trying to create an order page and allow the user to update the total of their order using a button (without having to submit the form). I'm calling an external JS file to make the necessary calcs based on the input selections made by the user, but when I click a "Calculate Total" button the form appears to submit and clears everything.
I'm confused as to how to define the form. Do you "POST" or "GET"? I'll eventually tie this to a PHP script on the action field, but I just want to do client-side updates for the order total so the user can see an updated total before they submit it.
<script type = "text/javascript" src="js/special_order_calcs.js"></script>
<form class="my_web_form" id="frmSpecialOrder" name="frmSpecialOrder" action="" method="">
... Here I do all my other fields definition, then ...
... Here is where the text box is created to store the calculated total ...
Order Total $: </strong><input class="my_form_input_short" type="textbox" id="ordertotal" name="ordertotal" readonly> USD
... Here's where I'm trying to update the order total within the JS file when the Calculate Total button is clicked ...
ot_final = qty1 + qty2 + qty3 + qty4 + ot_shipping_handling;
document.getElementById('ordertotal').value = ot_final;
// Set successful status
return true();
... Here are the button definitions ...
<!-- Create buttons -->
<button type="input" class="standard-button" onclick="calculate_total()" class="standard-button">Calculate Total</button> <button type="submit" class="standard-button">Submit</button> <button type="reset" class="standard-button">Reset</button></p>
I verified the calculation works via Alerts, so my goals is when I click Calculate Total, I'm expecting the updated calculation to show up in the 'ordertotal' textbox on the form so the user can see a new value if they change quantities, etc. without submitting the form. I know a zillion product websites use this and I'm just trying to do something simple. Thanks.