1
My problem is this, I have this code:
<script language="javascript">
$(document).ready(function(){
$('#simular').each(function(){
$(this).click(function(){
$("input[name=proteina2],input[name=quantidade2]").each(function(){
var proteina2 = Number($(this).val());
if (!isNaN(proteina2)) prot = proteina2;
alert(prot);
});
});
});
});
</script>
It takes the values of the fields named "proteina2" and "quantidade2" that loop in php showing values... What I need is not very difficult I believe, but as I am new in Jquery, I wanted help to better understand this part. I wanted to take the values of the "proteina2" and "quantity2" fields and sum them separately by taking all the values of the loop for these fields. For example, I have there:
Proteina2 | quantidade 2
5 10
4 2
In this case what I need is to take the whole loop of "proteina2" and add with "quantity2" and generate the following result:
resultado: 15
resultado: 6
This way it will add up all proteins or all amounts. I wanted a way for him to add the first protein with the first quantity, the second protein with the second quantity. and so on.
– Leo Ferreira
Ai needs its HTML structure to see how it will do.
– Guerra