0

I've 2 functions that works perfectly. I want to let them work together. One of them is a slider. see the code below.

        <script>
        $(function(){
            $(".cloudslider-handle").slider({
                range:"min",
                value:1,
                min:1,
                max:10,
                slide:function(event,ui){
                    $(".a,.b,.c,.d").width(ui.value * 10+"%");
                }
            });
            $(".ui-slider-handle").text("<>");
            $(".a,.b,.c,.d").width(10+"%");

        });
    </script>

And the other one is a speedometer. see the code below

        <script>

        document.addEventListener("DOMContentLoaded", function(event) {
            var gg1 = new JustGage({
                id: "gg1",
                formatNumber: true,
                counter: true
            });
        });

    </script>

How can i write the code so that when i slide the slider to a value say 2 for example that the value will be passed to the speedometer?

1
  • Oeps that was my fault. Changed it ;) Commented Sep 23, 2015 at 8:41

1 Answer 1

1

You can look at following code. May be that will help you a bit:

Please take a look at change: function( event, ui ) event handler added for slider. It gets the newer value from slider and refreshes the JustGage by calling gg1.refresh(newValue);

<script type="text/javascript">
    $(function(){

       var gg1 = new JustGage({
            id: "gg1",
            formatNumber: true,
            counter: true
        });

        $(".cloudslider-handle").slider({
            range:"min",
            value:1,
            min:1,
            max:10,
            slide:function(event,ui){
                $(".a,.b,.c,.d").width(ui.value * 10+"%");
            },

            change: function( event, ui ) {
                var newValue = ui.value * 10;
                gg1.refresh(newValue);
            }
        });
        $(".ui-slider-handle").text("<>");
        $(".a,.b,.c,.d").width(10+"%");

    });

</script>
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.