This code is used on a page for database hosting. The page has sliders from which a user selects the number of cores required and upper and lower limits of ram. The selected values from the slider are working and output in span id's. I then want to take the selected values to calculate a price. However I just cannot get back the value. I broke it down into simple parts and realise that there is no value being returned for cores or ram. What do I need to do to retrieve the values as and when the slider updates the page?
<script>
function showValues(event, ui) {
var values;
if (!ui.values) {
values = $("#" + event.target.id).slider("values");
}
else {
values = ui.values;
}
if (values[0] == values[1]) {
return false;
}
else {
values[0] % 1 == 0;
values[1] % 1 == 0;
$("#" + event.target.id + "-valuemin").html(parseInt(values[0]));
$("#" + event.target.id + "-valuemax").html(parseInt(values[1]));
}
}
$(document).ready(function() {
var base = 24;
var cores = parseInt($("#CoreSlider-valuemin").val()*5);
var ram = parseInt($("#RanSlider-valuemin").val()*2) + parseInt($("#RanSlider-valuemax").val());
var cost = parseInt(base) + parseInt(cores) + parseInt(ram);
$("#Cost").html(parseInt(cost));
});
$(function() {$( "#RanSlider" ).slider({range: true,min: 1,max: 64,step: 1,values: [4, 16],slide: showValues,create: showValues,change: showValues});});
$(function() {$( "#CoreSlider" ).slider({range: false,min: 1,max: 16,step: 1,values: [2],slide: showValues,create: showValues,change: showValues});});
</script>