Javascript values don't seen to be setting correctly
<p>I'm using Javascript to update some values of hidden form fields which are latter used to work out a total. This was working fine but now something odd seems to be happening and I'm at a lose to work out what.</p>

<pre><code> &lt;input type="hidden" name="membership[&lt;?php echo $row_id; ?&gt;][total]" class="&lt;?php echo $row_id; ?&gt;total" value="&lt;?php echo $social_prices[$row['membership']]; ?&gt;"&gt;
</code></pre>

<p>In my total function if I console.log the whole object I get:</p>

<pre><code> &lt;input type="hidden" name="membership[1][total]" class="1total" value="43.5"&gt;
</code></pre>

<p>but if I just grab the value I get the original value of the field, which is 24.. so the total is being worked out using the original values rather than the updated ones...</p>

<p>here's how I'm doing the console.log;</p>

<pre><code>console.log(this);
console.log((this.value));
</code></pre>

<p>This is how I'm updating the value:</p>

<pre><code>$('.'+membership+'total').val(total);
</code></pre>

<p>if I run this line right after that one I get back the right value: </p>

<pre><code>alert($('.'+membership+'total').val());
</code></pre>

<p>But when I try my total function it all goes wrong here is some of the code from the function I won;t post the whole lot cos it's really long.</p>

<pre><code>   var total = 0;
   $('input:hidden').each(function () {
   // I'm using this to make sure I get only the field I want to add together
  var result = name.match(/total/g);
  if((result)){
     console.log(this);
     console.log((this.value));
     total = total + parseFloat((this).value);
   } 
   });
</code></pre>
