Hello,
I am bignner in using JQuery with PHP, I have a form that culcalate the sum by using JQuery and displayed into HTML form, then I want to take this value from the form and inserted to the database by using PHP.
Could any body help me
HTML code:
<html>
....
<td style="border:1px solid #ccc; border-width:1px 1px 0 0;"><span id="sum5">0</span></td>
</html>
JQuery code:
<script>
$(document).ready(function(){
//iterate through each textboxes and add keyup
//handler to trigger sum event
$(".txtt").each(function() {
$(this).keyup(function(){
calculateSum();
});
});
});
function calculateSum() {
var sum5 = 0;
//iterate through each textboxes and add the values
$(".txtt").each(function() {
//add only if the value is number
if(!isNaN(this.value) && this.value.length!=0) {
sum5 += parseFloat(this.value);
}
});
//.toFixed() method will roundoff the final sum to 2 decimal places
$("#sum5").html(sum5.toFixed(2));
}
</script>