I have class:
function Slider(name,orientation,range,disabled,min,max,value) {
this.name = name;
this.orientation = orientation;
this.range = range;
this.disabled = disabled;
this.min = min;
this.max = max;
this.value = value;
this.setSlider = function() {
jQ("#"+this.name).slider({
orientation: ''+this.orientation,
range: this.range,
disabled: this.disabled,
min: this.min,
max: this.max,
value: value,
change: function(event, ui) {
this.value = jQ("#"+name).slider("option", "value");
console.log(value);
sprawdzSume();
}
});
};
}
And function to check sum of all sliders:
function sprawdzSume() {
var cena = 0;
if (slider3.value === 1) {
cena = slider1.value + slider2.value + slider3.value + 1 + slider4.value;
}
else{
cena = slider1.value + slider2.value + slider3.value + slider4.value;
};
if (cena > 7) {
jQ(function() {
jQ(slider5.name).slider({
value: 3
});
})
}
else if (cena > 5 && cena < 8) {
jQ(function() {
jQ(slider5.name).slider({
value: 2
});
})
}
else if (cena > 3 && cena < 6) {
jQ(function() {
jQ(slider5.name).slider({
value: 1
});
})
}
else {
jQ(function() {
jQ(slider5.name).slider({
value: 0
});
})
};
console.log(cena);
}
Function sprawdzSume() changing value of the last fifth slider. I want to pass a value of the slider to this function and then do some operations with that value. Here I have created some objects:
var slider1 = new Slider('slider1','vertical',false,false,0,1,1);
var slider2 = new Slider('slider2','vertical',false,false,0,3,3);
var slider3 = new Slider('slider3','vertical',false,false,0,1,1);
var slider4 = new Slider('slider4','vertical',false,false,0,3,3);
var slider5 = new Slider('slider5','vertical',false,true,0,3,3);
How can I get a changed value of the each slider and then do some operations on them?
var selection = $(“#slider1”).slider(“ value”);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.