djmcr Posted November 14, 2007 Share Posted November 14, 2007 I have a javascript code that calculates the total price from a form. The data from the form is then emaild to me. All the data comes through except the total. Here is the line which displays the total. " <fieldset> <b>Total: $ <div id="calculation" name="total" style="display:inline;">0</div><br /></b> </fieldset> " Here is the line in my php. " Total Price: ".$total." " I have tried using the id tag in php as well as the name tag, I don't know where to go from here. The order page can be found at "www.djmcr.com.au/ade/order.html" Please help I have been banging my head against a wall for a three weeks about this. Link to comment https://forums.phpfreaks.com/topic/77247-calculation-wont-send-in-email/ Share on other sites More sharing options...
Daukan Posted November 14, 2007 Share Posted November 14, 2007 Make a hidden form field with the total. Then access it thru the post vals Link to comment https://forums.phpfreaks.com/topic/77247-calculation-wont-send-in-email/#findComment-391068 Share on other sites More sharing options...
kellz Posted November 14, 2007 Share Posted November 14, 2007 I would just write it all in PHP.. there is no need for javascript really (in most cases) Link to comment https://forums.phpfreaks.com/topic/77247-calculation-wont-send-in-email/#findComment-391069 Share on other sites More sharing options...
teng84 Posted November 14, 2007 Share Posted November 14, 2007 div is not part of the form so what ever you do you cant submit the value inside the div like the other member said place your value in a hidden field <input type="hidden" name="textfield" value ="your value"/> Link to comment https://forums.phpfreaks.com/topic/77247-calculation-wont-send-in-email/#findComment-391073 Share on other sites More sharing options...
kellz Posted November 14, 2007 Share Posted November 14, 2007 div is not part of the form so what ever you do you cant submit the value inside the div like the other member said place your value in a hidden field <input type="hidden" name="textfield" value ="your value"/> But doesn't the page reload? I only just thought of that so writing it in php wouldn't be any good either^^ like every time the price is calculated the page will reload... ??? Link to comment https://forums.phpfreaks.com/topic/77247-calculation-wont-send-in-email/#findComment-391077 Share on other sites More sharing options...
teng84 Posted November 14, 2007 Share Posted November 14, 2007 div is not part of the form so what ever you do you cant submit the value inside the div like the other member said place your value in a hidden field <input type="hidden" name="textfield" value ="your value"/> But doesn't the page reload? I only just thought of that so writing it in php wouldn't be any good either^^ like every time the price is calculated the page will reload... ??? the thread starter said he has a JS that calculates etc... so no need to reload JS will give the desired value on the hidden field eg... onclick assign the value on the hidden field im some reason maybe reloading the page looks odd. if you have say... ten calcualtion to process would you want your page to reload ten times? cheers... Link to comment https://forums.phpfreaks.com/topic/77247-calculation-wont-send-in-email/#findComment-391081 Share on other sites More sharing options...
kellz Posted November 14, 2007 Share Posted November 14, 2007 div is not part of the form so what ever you do you cant submit the value inside the div like the other member said place your value in a hidden field <input type="hidden" name="textfield" value ="your value"/> But doesn't the page reload? I only just thought of that so writing it in php wouldn't be any good either^^ like every time the price is calculated the page will reload... ??? if you have say... ten calcualtion to process would you want your page to reload ten times? cheers... errr probably not^^ I just got the wrong idea.. cheers... Link to comment https://forums.phpfreaks.com/topic/77247-calculation-wont-send-in-email/#findComment-391086 Share on other sites More sharing options...
djmcr Posted November 14, 2007 Author Share Posted November 14, 2007 Thanks for the help so far. I have not been able to work out how to make the result of my javascript calculation be the value of the hidden field. The total amount is calculated correctly and displayed on screen but still won't send as part of the form email. The javascript is as follows. <script type="text/javascript"> function recalculate() { var value = 0; if(document.getElementsByName('adepoem')[0].checked) {value += 20;} if(document.getElementsByName('a4')[0].checked) { value+=document.getElementsByName('a4q')[0].value*20; } if(document.getElementsByName('cards')[0].checked) {value += 20;} document.getElementById('calculation').innerHTML=value; }; </script> Link to comment https://forums.phpfreaks.com/topic/77247-calculation-wont-send-in-email/#findComment-391205 Share on other sites More sharing options...
gin Posted November 14, 2007 Share Posted November 14, 2007 This should be in your form: <input type="hidden" name="hiddenTotal" /> This should be in your javascript: document.getElementById('hiddenTotal').value=value; Link to comment https://forums.phpfreaks.com/topic/77247-calculation-wont-send-in-email/#findComment-391246 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.