0

I have problem with jquery function. I am trying to work with variable from jquery form slider and I have this script.

$(document).ready(function () {

$("#slider-amount").slider({
  range: "min",
  value: 10,
  step: 10000,
  min: 100000,
  max: 1000000,
  slide: function( ev, ui ) {
    var amountValue = ui.value;
    $("#amount").text(ui.value);
    process(amountValue);
  }
 });

$("#slider-year").slider({
  range: "min",
  value: 10,
  step: 1,
  min: 5,
  max: 15,
  slide: function( ev, ui ) {
    var yearSlider = ui.value;
    $("#year").text( ui.value );
    process(yearSlider);
  }
});

function process(yearSlider, amountValue){
    var valueFromSlider = amountValue;
    console.log(valueFromSlider);
    if(lc_jqpost_info[valueFromSlider] !== undefined) {
     document.getElementById("vypocet_splatka").innerHTML = lc_jqpost_info[valueFromSlider];
    };
}

});

The problem is that in console work only yearSlider value and second amountValue show status undefinated.

Thank you for your help.

4
  • 2
    You just call the process() function with one parameter, process(yearSlider). Then the second parameter will be undefined Commented Jan 19, 2014 at 19:58
  • Ok can you help me how to solve this problem, because I need to use two parameters. Commented Jan 19, 2014 at 20:28
  • What values do you want to send to process() then, one from each slider, both from the same slider ? Commented Jan 19, 2014 at 20:33
  • One value from each slider like I wrote it in first post. It mean that I need amountValue and yearSlider in one function. Thank you for your help. Commented Jan 19, 2014 at 20:43

1 Answer 1

1

One way to do it could be to access the values from the DOM:

function process(){
    var yearVal = $("#year").text();
    var amountVal = $("#amount").text();
    /*rest of your code*/
}

Another is to get it from the slider:

function process(){
    var yearVal = $("#year").slider().data().uiSlider.value();
    var amountVal = $("#amount").slider().data().uiSlider.value();
    /*rest of your code*/
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much for your fast help first process work exactly as I need. Again thank you :D

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.