function calc(obj){
var value =obj.value;
var cls = obj.className;
var texts = document.getElementsByClassName(cls);
var a = texts[0].value;
var b = texts[1].value;
a = parseFloat(a);
b= parseFloat(b);
a = isNaN(a) ? 0 : a;
b = isNaN(b) ? 0 : b;
var sum = a * b;
document.getElementsByClassName(cls + cls)[0].textContent = sum;
calTotal();
}
function calTotal(){
var arr = document.querySelectorAll('.aa,.bb,.cc,.dd,.ee,.ff,.gg,.hh,.ii,.jj,.kk,.ll,.mm,.nn,.oo,.pp,.qq,.rr')
var total = 0;
for(var i = 0; i <arr.length; i++){
var value = arr[i].textContent;
value = parseFloat(value);
value = isNaN(value)? 0:value;
total+= value;
}
document.getElementsByClassName('total')[0].textContent = total;
};
$(function() {
$( "#datepicker" ).datepicker({
changeMonth:true,
changeYear:true,
yearRange:"-100:+0",
dateFormat:"dd/mm/yy"
});
});
</script>
<style>
.aa, .bb, .cc, .dd, .ee,.ff,.gg,.hh,.ii,.jj,.kk,.ll,.mm,.nn,.oo,.pp,.qq,.rr, .total{
font-size: px;
font-weight: bold;
}
.headerb{
width:555px;
height:130px;
border:1px solid red;
}
.setup{
width:600px;
border: 1px dotted green;
float:center;
}
</style>
Product Discription | Unit Price | + | Quantity | = | Amount |
+ | = | ||||
+ | = | ||||
+ | = | ||||
+ | = | ||||
Total | |||||
</body>
It looks like you're new here. If you want to get involved, click one of these buttons!