1

I want to update a jquery ui range slider with the values that are in two text boxes.

var minVal = $(this).find('.minTextBox').val();                  
var minVal2 = parseInt(minVal);
var maxVal = $(this).find('.maxTextBox').val();
var maxVal2 = parseInt(maxVal);
var myvalues = [minVal2, maxVal2];

var mySliderId = $(this).find('.RangeSlider').attr('id');

$( "#" + mySliderId).slider({
    range: true,
    values: myvalues,
    slide: function( event, ui ) {
        var idx = $(this).attr("id");
        x = idx.substr(idx.length-2);
        $( "#ctl00_ContentPlaceHolder1_Min"  + x ).val(ui.values[0]);
        $( "#ctl00_ContentPlaceHolder1_Max"  + x ).val(ui.values[1]);
    }
});

I'm trying to pass the myvalues array to the slider to overwrite the old values.

No matter what I try, I can't get this to work. I've looked at various other questions on SO and through the documentation but I can't get any closer.

Am I on the right lines with this?

Any help would be appreciated.

4
  • A jsfiddle of the page would be appreciated too. Commented Oct 9, 2012 at 12:03
  • Seems to work jsfiddle.net/YSEGU/1 . Commented Oct 9, 2012 at 12:17
  • I can't really make an accurate fiddle for this. The values for the text boxes are pulled from a database when the page loads and I need my range slider to set itself to the values that are in those text boxes. Commented Oct 9, 2012 at 13:06
  • managed to resolve this by doing the following: $('#' + mySliderId).slider("values",0,minVal2); $('#' + mySliderId).slider("values",1,maxVal2); Commented Oct 9, 2012 at 14:03

1 Answer 1

1

You don't need to initialize again. execute the below line to modify the range values.

$( "#" + mySliderId).slider( "option", "values", myvalues );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.