I’m trying sum many values from radio buttons, but I’m with some problems in my logical thinking,
I put my source code here to a better visualization.
so, for exemplo I have the product_price = 9.00 and a radio = 2.00 and another radio, radio2= 0.00
If I check the radio, the sum will be sum = product_price + radio, but the problem is when I change the radio for radio2, it isn’t work fine.
thanks
I don’t know if I understand it right….
But I guess that are you trying sum just if that option have some price…
If is this, you need be careful with the value that you are adding.
First, make a global variable called price. And set it to zero. That will be a price that you will add IF it is necessary. The default configuration, this value will be zero… so set it to zero.
When you change a option, first remove the old plus value from our total. Then you check if this option has some value to plus…. if it has, you have to update your global variable, and add this new value to total.
Look up the code for more details!
http://jsfiddle.net/zEaw6/17/
});
Kind regards!