2

I have 3 connected jquery ui sliders where the value is reflected in input fields next to them.

See http://jsfiddle.net/oniiru/gWbMp/

As it is now, the value of the input changes as I slide the sliders, but I can't figure out how to change the value of the slider if I type a new value into the input. I know there are other examples of this out there, but not with connected sliders and I somehow can't get it working. Could anyone help? Sorry I'm pretty new to this, and any help would be appreciated.

As a side note, the slider handles also pass beyond the end of the slider, and if someone wanted to help me figure out how to fix that as well I would certainly appreciate it. :)

thanks all,

1 Answer 1

1

Use following code: modified jsfiddle

    $("input").change(function(){

         var index = $(this).attr('class').substring(0,1);
        $("#slider_"+ index).slider('value', this.value);
        refreshSliders( index - 0 );
});

Note:You should not use same Id for more than one element. (you are using same id for all inputs).

Sign up to request clarification or add additional context in comments.

5 Comments

Hey Sushil, thanks so much for the help. It's really close, and I actually have tried a similar approach in the past, but for some reason the values don't always add up to 100% like they did originally. Most of the time, it seems that if I add any number into the boxes only the corresponding slider will change and the rest will stay the same, meaning that it can add up to over 100%. do you have any ideas on how to keep the connection between sliders? Thanks again so much for the help.
I made the chnages in code. I am using refreshSliders( index ); to relate slider I think now it working fine. check once jsfiddle.
thanks again, seems like it works better now, but still isn't quite there. If you enter 99 in the first input for instance right after load, the bottom slider reads 11 so obviously adds up to over 100%. The weird thing is when you move the sliders around a bit, and enter 99, it works perfectly. It also seems to round up, so if I enter 77 for instance, instead of making one 11 and the other 12, it makes both 12 and adds up to 101%. Is there any way to fix this? Again, thanks os much. This seems to be way over my head...
If it happening first time only then there may be some initialization problem. I edited jsfiddle to make button position more accurate. you can debug your code using developer tools. I am sorry, I don't have much time to look into your code.
Thanks so much, I really do appreciate you taking the time to help me out.

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.