Hi,
At www.happydaysremovals.com.estimatenew.html. Users fill in a form which has items of furniture, so they enter a number next to each item of furniture. The HTML uses text fields.
When the form is submitted, the form is submitted to a php script that emails the results to myself.
I am trying to also have a javascript function which runs before the php script runs. This javascript works out the cubic footage of all the items. If a user put "3" in the sofa text field, and I have defined that a sofa is 45 cubic feet, then the javascript will multiply 3 * 45. It will do a similar thing for all items of furniture, then add them all up to give a total cubic feet. I want that total field to then sent as a variable to the php script, along with all the other variables.
My code so far (which doesnt work)
I have used a hidden field for the total value:
I want the javascript result to change the value of the hidden field that is called total.
THen I want it all to be posted to the PHP script and email everything to me, including this newly calculated total field!
THanks
At www.happydaysremovals.com.estimatenew.html. Users fill in a form which has items of furniture, so they enter a number next to each item of furniture. The HTML uses text fields.
When the form is submitted, the form is submitted to a php script that emails the results to myself.
I am trying to also have a javascript function which runs before the php script runs. This javascript works out the cubic footage of all the items. If a user put "3" in the sofa text field, and I have defined that a sofa is 45 cubic feet, then the javascript will multiply 3 * 45. It will do a similar thing for all items of furniture, then add them all up to give a total cubic feet. I want that total field to then sent as a variable to the php script, along with all the other variables.
My code so far (which doesnt work)
Code:
<script language="JavaScript"> function calculate() { var sofa_3_seater = document.getElementById('sofa_3_seater').value*45; var sofa_2_seater = document.getElementByID('sofa_2_seater').value*30; var armchair_large = document.getElementByID('armchair_large').value*15; var total=sofa_3_seater+sofa_2_seater+armchair_large; document.getElementByID('total').value = total; } </script>
Code:
<input type="hidden" name="total" value="">
THen I want it all to be posted to the PHP script and email everything to me, including this newly calculated total field!
THanks
Comment