function calculateTotal() {
var Power = document.getElementsByClassName("power_required")[0].value;
console.log(Power);
}
which works as expected, the value of the element appears in the console. How do I grab all the values in the array and loop through it to get the sum of all the values?
function calculateTotal() {
var Power = document.getElementsByClassName( 'power_required' ), total = 0;
for ( var c = 0; c < Power.length; c ++ ) {
total += parseFloat( Power[ c ].value );
}
console.log( total );
}