[jQuery] Re: Adding values from a variable number of select drop downs

2009-03-07 Thread ricardobeat
function weightTotal(){ var total = 0; $('.weight').each(function(){ total += +$(this).val(); //if it's an empty string +"" == 0 }); $('#grand_total').html( total + "%" ); } cheers, - ricardo On Mar 6, 9:58 pm, shallowman wrote: > Hello all, > > I am trying to add the values

[jQuery] Re: Adding values from a variable number of select drop downs

2009-03-06 Thread mkmanning
temp is undefined, so you're adding undefined to the first value in your loop. Set temp = 0; Also, unless you're planning on using it elsewhere, you don't need to assign var obj. And, is there any reason you're using document.getElementById("grand_total").innerHTML instead of $ ('grand_total').ht