I have a little problem with jquery ui slider and checkboxes.
Full code is like this:
$(function() {
var slider = function(event,ui){
var currentvalue = ui.value || $( this ).slider( "option", "value" );
if ( $('#netocheck').prop("checked") ){
var tooltip = $(".tooltip").html(currentvalue + "€");
var neto = $( ".neto" ).html(currentvalue);
var fond = $( ".fond" ).html(currentvalue + 1000);
var sotsiaalmaks = $( ".sm" ).html((currentvalue * 33) / 100);
var tulumaks = $( ".tm" ).html((currentvalue * 21) / 100);
var kl = $( ".kl" ).html((currentvalue * 2) / 100);
var bruto = $( ".bruto" ).html(currentvalue);
}
else ( $('#brutocheck').prop("checked") ) {
var tooltip = $(".tooltip").html(currentvalue + "€");
var bruto = $( ".bruto" ).html(currentvalue + "€");
var neto = $( ".neto" ).html("neto");
}
};
$('input.check').on("change", function() {
$("input.check").not(this).prop("checked", false);
});
$("#slider-range").slider({
value: 1000,
min: 100,
max: 2000,
step: 100,
slide: slider,
create: slider
});
});
I want that this IF part (and maybe whole slider) work every time i check one of two checkboxes. So checking one checkbox add some values to variables and checking another add different values to same variables.
My added part:
if ( $('#netocheck').prop("checked") ){
var tooltip = $(".tooltip").html(currentvalue + "€");
var neto = $( ".neto" ).html(currentvalue);
var fond = $( ".fond" ).html(currentvalue + 1000);
var sotsiaalmaks = $( ".sm" ).html((currentvalue * 33) / 100);
var tulumaks = $( ".tm" ).html((currentvalue * 21) / 100);
var kl = $( ".kl" ).html((currentvalue * 2) / 100);
var bruto = $( ".bruto" ).html(currentvalue);
}
else ( $('#brutocheck').prop("checked") ) {
var tooltip = $(".tooltip").html(currentvalue + "€");
var bruto = $( ".bruto" ).html(currentvalue + "€");
var neto = $( ".neto" ).html("neto");
}
And checkboxes:
<span class="check1"><input id="netocheck" class="check" type="checkbox" checked>1</span>
<span class="check2"><input id="brutocheck" class="check" type="checkbox">2</span>