There are 2 select fields, each of which has 18 values, from 1 to 18.
Now I have a calculator that is very simple - it calculates the difference between the past and the current value and multiplies it by 100:
var current_rank, new_rank; $('#rank1').change(function(){ current_rank = parseInt($(this).val()); var result = (new_rank - current_rank) * 100; console.log(result); }); $('#rank2').change(function(){ var new_rank = parseInt($(this).val()); var result = (new_rank - current_rank) * 100; console.log(result); }); But then the question arose: How to make coefficients for these values? Those. To from 1 to 6 the price was 100, from 7 to 12 - 300 and from 13 to 18 - 500?
For examples, to make it clearer: A person chooses from the first field a value of 3, from 2 fields a value of 6. All values are in the range from 1 to 6, therefore, (6-3) * 100 = 300.
The value of 1 field is 5, the value of 2 field is 9 Now it happens like this: (9-5) * 100 = 400, but I need it to be calculated in a different way, because this includes the value 6, the price of which is 100, and also the values 7 8 and 9, the price of which is 300. Therefore, the result will be as follows: 100+ (300 * 3) = 1000
How to do it, who knows? But even there are no thoughts, although everything seems to be just ...