Possible Duplicate:
How do I Convert a String into an Integer in JavaScript?
I have a select element that contains options for products. What I want to achieve is when they pick an option the price on the page automatically adjusts. I have figured out how to retrieve those values but when I combine them it just puts two numbers together instead of actually adding them.
For example instead of outputting 60 when I have 50 + 10 it outputs 5010.
My code:
$(\'.product_options\').change(function(){
var base_price = $(\'#base_price\').html();
var add_price = $(this).find(\"option:selected\").data(\'price\');
var new_price = base_price+add_price;
console.log(new_price);
$(\'.current_price\').html(base_price+add_price);
});
Is there a way I can convert them both to integers so the operation actually goes through?
Thanks in advance!





Rating:
The post Combining retrieved values with javascript and jquery appeared first on Javascript ASK.
via Javascript ASK http://javascriptask.phpfogapp.com/combining-retrieved-values-with-javascript-and-jquery.html
No comments:
Post a Comment