3
I have in a table, several label ex:
<td style="width:10%"><label id="PrecoProd_3" class="negrito">R$ 1.502,25</label></td>
There are several lines with this type, changing only id
I’d like to put it down at a certain place on page one <label></label>
with the total sum
I could do jquery, pure javascript, anyway, but I haven’t been able to isolate the fields, since I don’t know the ID (can have several lines, so I can’t refer to the label id (I believe)
tried to do so
function id(el) {
return document.getElementById(el);
}
function somaLabel() {
//Produtos - é o ID da tabela,
var inputs = id('Produtos').getElementsByTagName('label');
var soma = 0;
for (var i = 0; i < inputs.length; i++) {
soma += parseInt(inputs[i].value);
}
alert(soma);
//id('resultado').value = soma;
}
Alert is giving NAN Alert just for testing, because I tried to do on the final label. Example of the application:
Your values have commas sometimes and points in others. You can correct these values or you have to work with them as they are?
– Sergio
I think to standardize...I just need to correct the other js, but yes
– Dorathoto