I have a few variables:
var test1 = 1500;
var test2 = 500;
var test3 = 3000;
var test4 = 20000;
And I have an another variable like this:
var list = 'test3,test1';
This is not fixed obviously, so that can be 'test4,test1,test2' etc..
Now, I need a price variable. test3+test1 = 4500
var price = '4500';
But I don’t have any idea how to do that. Here is what I have so far:
var names = [];
$(':checkbox:checked').each(function() {
names.push(this.name);
});
var list = names.join(',');
Any ideas?
You should change your variables into a proper object:
Now you can add like so: