This is a migrated thread and some comments may be shown as answers.

Setting Slider Value

1 Answer 27 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 15 Feb 2013, 03:43 AM
Hi

Is it possible to set the value of RadSlider through JavaScript based on a value in my textbox?  When I enter some value in the textbox then the slider should be set accordingly and vice-versa.
Thanks
Ben.

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 15 Feb 2013, 04:33 AM
Hi Ben,

It is possible to set the slider value through Javascript. Please have a look into the following code snippet to set the slider value from textbox as well as to set the textbox value from the slider. You can use the OnClientValueChanged event of the RadSlider to set the textbox value when the slider position is changed.

ASPX:
<asp:TextBox ID="TextBox1" runat="server" onblur="myFunction()"></asp:TextBox>
<telerik:RadSlider ID="RadSlider" runat="server" MinimumValue="0" MaximumValue="100"
    OnClientValueChanged="OnClientValueChanged">
</telerik:RadSlider>

Javascript:
<script type="text/javascript">
    function OnClientValueChanged(sender, eventArgs) {
        document.getElementById("TextBox1").value = sender.get_value();
    }
 
    function myFunction() {
        var slider = $find("<%= RadSlider.ClientID %>");
        slider.set_value(parseInt(document.getElementById("TextBox1").value));
    }
</script>

Thanks,
Princy.
Tags
Slider
Asked by
Ben
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or