So it won't work to move the Javascript total into a hidden field - as below (which I tried):
In js script:
document.getElementById('subtotal').value = '$ ' + runningTotal.toFixed(2);
On HTML form:
<input type="hidden" id="subtotal" name="subtotal" value="">
In php script:
$sub_total = $_POST['subtotal'];
I am guessing it isn't possible, although I don't understand why I can get that total into a div tag, and not into a hidden field that I can then $_POST to my php form.
This part works:
js script:
document.getElementById('sub_total').innerHTML = '$ ' + runningTotal.toFixed(2);
HTML form:
<div class="price" id="sub_total" name="sub_total"> $0.00</div>
And using onBlur to call the js function, the total is updated everytime someone tabs out of a qty field.
So why can that total make it to the div tag and not the hidden field? If I could just get it to the hidden field, I could pass it to the php script...right?
Also - I'm confused by the naming of the js code getElementById. It seems like this code is "putting" my subtotal (the runningTotal.toFixed(2) piece?) into the div tag - correct? So I don't understand why it is call "getElement". I'm assuming that I don't really understand what's happening. Can someone explain?
Thanks for your help.
P.S. At this point I've spent a million hours on this project, just trying to figure out this last piece, so if someone has a better suggestion for how to have implemented this, I'd appreciate learning to do it the "right" way...
I have an order form that needs to calculate a running total of items ordered, and show the totals as they go (all on one page) and then send all the info by email once the order is complete. (no payment function needed).