Hi guys (and girls) !
I'm trying to make a script that adds up the price of selected items and shows the total price.
Something like when configuring a iMac of MacBook at the apple.com store
There is a basic price, lets say $100.
If you click on extra item #1, it gets a class .selected and the value of item #1, lets say $10 sould be added to $100 so the total is $110.
Not very complicated concept, but i'm not very good with JS/jQ. Here's what I've got so far.
Appriciate your help!
- <script type="text/javascript" charset="utf-8">
$(document).ready(function () {
var basicprice = 100;
var price = '';
$(".product").click(function() {
if($(this).hasClass("selected")) {
$(this).removeClass("selected");
} else {
$(this).addClass("selected");
}
});
// Something missing here...
var total = basicprice + price;
$('#price').html(total);
})
</script>