Good point. Try this to limit it to the proper set of inputs: $(this).parents().filter('.productInfo').find('input:checked').each(function() { aditionalValue += Math.ceil($(this).val()); });
On Sun, May 31, 2009 at 9:38 PM, Ignacio Ricci <ignacio.ri...@gmail.com> wrote: > > Hi Brian. I didn't see that, your definetely right. > I changed what you told me, and it appeared fixed initially. However > when you check some checkboxes from one list, > and then check others in the other list, the prize gets affected > weirdly. > > Anyway we're closer to the solution. > Thank you :) > > Ignacio > > > On May 31, 9:28 pm, brian <bally.z...@gmail.com> wrote: >> Change this: >> >> $('.productAditionals >> input').parents().filter('.productInfo').siblings().filter('.productBuy').find('strong >> span').text(aditionalValue); >> >> to: >> >> $(this).parents().filter('.productInfo').siblings().filter('.productBuy').find('strong >> span').text(aditionalValue); >> >> Within the 'change' event handler, 'this' refers to that specific >> input. When you use '.productAditionals input', you're selecting all >> of them. The first part works properly because you're applying the >> event handler to all of the inputs. But, when you use that same >> selector the 2nd time, you're again selecting all of them, so the new >> text is applied to all of spans. >> >> There's probably even a better way to mark this up so that the >> selectors are simplified, but this works. >> >> On Sun, May 31, 2009 at 8:53 PM, Ignacio Ricci <ignacio.ri...@gmail.com> >> wrote: >> >> > Hi there. I'm not very good with Jquery and JS yet, so I'm having a >> > bit of a problem trying to achieve this. >> >> > What I need to do is explained here: >> >http://ignacioricci.com/alphas/jquery-issue.gif >> >> > And here is my actual code: >> >http://ignacioricci.com/alphas/jquery-issue.html >> >> > Is working in a way, but it's buggy. This bug is explained in the gif >> > image. >> >> > Thank you for your help, >> > Ignacio >