Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting jquery slide value when user stop moving slider

I have slide and gettig values using jquery.

JS:

    var setRatingValue = function() {
        // Set text
        var ratingValue = $("#rating-slider").slider("value");
        $("#rating-value").text(ratingValue);
        // Change the background colour of the slider
        var hsl = "hsl("+ratingValue+", "+50+"%, "+50+"%)";
        $(".ui-slider-range").css("background", hsl);
        // Set text colour
        $("#rating-value").css("color", hsl);
   alert(ratingValue);

    };

html:

    <div class="magic-bar">
        <span id="rating-slider" class="ui-slider-range"></span>
        <span class="flip">
            <a href="#"> FLIP </a>
        </span>
    </div>

ratingValue gives rated values when user move slider. I need to post this final selected value to someother file.

But problem : When I move slider, it continuously keep alerting the value of slider. So I i post it, it will post each value on slider.

What I want: When user stops moving slider then only the value should be alerted. So that I can post single final value.

Any idea how to do this?

like image 761
Programming_crazy Avatar asked Nov 02 '22 07:11

Programming_crazy


1 Answers

populate an (hidden) input field with the ratingValue, When you post you'll send the current value

html:

<input id="myValue" value="">

javascript:

 $("#myValue").val(ratingValue)
like image 76
Vickel Avatar answered Nov 13 '22 22:11

Vickel