Note that there are some explanatory texts on larger screens.

plurals
  1. POadding two variables together
    primarykey
    data
    text
    <p>I have been trying for... about 4 hours now lmao.</p> <p>currentCalc returns 50 currentSum returns 0 when i alert them. Yet I cannot add them together with parseInt????</p> <p>what am i doing wrong :'(</p> <pre><code>var identRow = $('tr.identRow'); identRow.each(function () { var getIdentClass = $(this).attr('class').split(' ').slice(1); $('tr.ohp' + getIdentClass + ' td.EURm').each(function (index) { var currentCalc = parseInt($(this).text().replace('.', ''), 10); var currentSum = $('tr.' + getIdentClass + ' td.totalEURm', this).text().replace('.', ''); total = parseInt(currentCalc, 10) + parseInt(currentSum, 10); $('tr.' + getIdentClass + ' td.totalEURm').text(total); if (index == 6) { alert(total); } }); }); </code></pre> <p>EDIT:</p> <p>Oh goodness. Im completely confused now. I putr the break there. It says total = 50.</p> <p>I want each iteration to add itself to the total. That is why I add currentCalc to the text of the field im plopping the currentCalc into.</p> <pre><code>$('tr.' + getIdentClass + ' td.totalEURm').text(total); </code></pre> <p>with my code now like this:</p> <pre><code> var identRow = $('tr.identRow'); identRow.each(function () { var getIdentClass = $(this).attr('class').split(' ').slice(1); $('tr.ohp' + getIdentClass + ' td.EURm').each( function (index) { var currentCalc = parseInt($(this).text().replace('.', ''), 10) || 0; var currentSum = parseInt($('tr.' + getIdentClass + ' td.totalEURm', this).text().replace('.', ''), 10) || 0; var total = currentCalc + currentSum; $('tr.' + getIdentClass + ' td.totalEURm').text(total); if (index === 6) { alert(total); } }); }); </code></pre> <p>it alerts: 50, then 0, then 50, then 0.</p> <p>EDIT:</p> <p>How do I add currentCalc to its last value?</p> <p>So first iteration its 10, seconds its 20. How do i make it so on the 2nd iteration it equals 30. currentCalc++ is just adding 1 to it. </p> <p>Now you understand how crap i am :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload