While working on an e-commerce site, I needed to update my order total and submit it with the other form variables. My order total displayed to the user was just text, which doesn't get passed to the controller when submitted, so I needed a hidden input that I could update.
and my javascript. (snippet is from an UpdateTotal() function)
My html looks like this:
<p class="display_currency"><span id="totalprice">$0.00</span></p><%= Html.HiddenFor(m=>m.TotalOrder) %>
var total = 500.25
$("#totalprice").html("$" + total.toFixed(2));
$("#TotalOrder").val(total.toFixed(2)); //hidden control for model
No comments:
Post a Comment