Link to home
Start Free TrialLog in
Avatar of ToString1
ToString1

asked on

Set jquery slider value in code


I have implemented wizard steps in MVC and am trying to use a jquery slider to advance on step as you progress through wizard.

I am providing the total number of questions and the current question via hidden values.  

For some reason the slider is not progressing;


  <script type="text/javascript">
        var i = $('input[name=NumberTotal]').val();
        var x = $('input[name=ThisNumber]').val();
   
        $(function() {
            $("#slider-range-max").slider({                
                range: "max",
                min: 1,
                max: i,
                value: x,
                slide: function(event, ui) {
                                x = ui.value
                }
            });
            $("#question").val($("#slider-range-max").slider("value"));
        });
      </script>


Why is this not working?
ASKER CERTIFIED SOLUTION
Avatar of Bardobrave
Bardobrave
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ToString1
ToString1

ASKER

Hi folks

Thanks for your replies.   Yes I am using 1.8 or above

Could you provide a code snippet?

I want the slider to be moved by code and not allowed by mouse

Thanks
Forgot to say

I am loading new view each time I click wizard step so it is refreshed every time
I tried your solution but I did not get an alert popup
Then maybe

var i = $('input[name=NumberTotal]').val();

and

var x = $('input[name=ThisNumber]').val();

are not getting the values you think they'd get? Have you tried to alert them on every step of the wizard to check that the values are being correctly passed to the slider?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi

I am definately getting the values from the hidden inputs on the view and the code is correct hmm..
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial