Кусок JS:
<script type="text/javascript">
// JavaScript Document
var p = {
0: "100",
1: "1000",
2: "2000",
3: "3000",
4: "4000",
5: "5000",
6: "6000",
7: "7000",
8: "8000",
9: "9000",
10: "10000",
11: "11000",
12: "12000",
13: "13000",
14: "14000",
15: "15000",
16: "16000",
17: "17000",
18: "18000",
19: "19000",
20: "20000",
21: "21000",
22: "22000",
23: "23000",
24: "24000",
25: "25000",
26: "26000",
27: "27000",
28: "28000",
29: "29000",
30: "30000",
};
var t = {
0: "99",
1: "390",
2: "780",
3: "1170",
4: "1560",
5: "1950",
6: "1990",
7: "2320",
8: "2650",
9: "2980",
10: "3310",
11: "3430",
12: "3740",
13: "4050",
14: "4360",
15: "4680",
16: "4680",
17: "4970",
18: "5260",
19: "5550",
20: "5850",
21: "5730",
22: "6000",
23: "6270",
24: "6550",
25: "6820",
26: "6590",
27: "6840",
28: "7090",
29: "7350",
30: "7600",
}
var obj = {
'24sex' : {
'quarterly' : '1',
'sexly' : '1.3',
'weekly' : '1.3'
},
'18sex' : {
'quarterly' : '1.3',
'sexly' : '1.6',
'weekly' : '1.6'
},
'12sex' : {
'quarterly' : '1.3',
'sexly' : '1.6',
'weekly' : '1.6'
}
};
$(document).ready(function() {
$("#total").val("10000");
$("#slider_amirol").slider({
range: "min",
animate: true,
min: 0,
max: 30,
step: 1,
slide:
function(event, ui)
{
update(1,ui.value); //changed
calcualtePrice(ui.value);
}
});
$('.sex').on('click',function(event) {
var id = $(this).attr('id');
$('.sex').removeClass('selected-sex');
$(this).addClass('selected-sex');
$(".sex").removeClass("active-sex");
$(this).addClass("active-sex");
$('#sex').val(id);
calcualtePrice()
});
$('.term').on('click',function(event) {
var id = $(this).attr('id');
$('.term').removeClass('selected-term');
$(this).addClass('selected-term');
$(".term").removeClass("active-term");
$(this).addClass("active-term");
$('#term').val(id);
calcualtePrice()
});
update();
calcualtePrice();
});
function update(slider,val) {
if(undefined === val) val = 0;
var amount = p[val];
$('#sliderVal').val(val);
$('#slider_amirol a').html('<label><span class="glyphicon glyphicon-chevron-left"></span><span style="font-size:18px; color:#fff;"> '+amount+' </span><span class="glyphicon glyphicon-chevron-right"></span></label>');
}
function calcualtePrice(val){
if(undefined === val)
val = $('#sliderVal').val();
var sex = $('#sex').val();
var term = obj[sex][$('#term').val()];
var totalPrice = t[val]*term;
$("#total").val(totalPrice.toFixed(0));
$("#total12").val(Math.round(((totalPrice*15/100)*100)/totalPrice).toFixed(0));
$("#total52").val(Math.round((totalPrice)/52).toFixed(0));
}
</script>
Нужно, чтобы вот это поле: $out_summ = '99'; автоматически заменялось ценой из ползунка.
Сам калькулятор вот:
http://www.like77.ru/page1