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?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With