Javascript equivalent of onchange()

2 posts, 0 answers
  1. Keith
    Keith avatar
    23 posts
    Member since:
    Jan 2013

    Posted 28 Oct Link to this post

    I would like to fire a RadComboBox's SelectedIndexChanged event from another function in JS.  For a standard dropdown list I would use "onchange()" but for the RadComboBox I get TypeError: RadComboBox1.onclick is not a function.  Is there a way to fire a selectedindexchanged event from javascript on a radcombobox?

     

    Example:

    function fireSelectedIndexChanged() {
        var comboBox = $find("<%=RadComboBox1.ClientID%>");
        comboBox.onchange(); <---- fire selectedindexchanged event
    }


  2. Anton
    Admin
    Anton avatar
    61 posts

    Posted 01 Nov Link to this post

    Hello Keith,

    In order the SelectedIndexChanged event to be fired there has to be a selection on the items in the ComboBox. You can fire it by selecting a different item from the currently selected item and you could do that from any function. Take a look at the code below:

    <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server"></telerik:RadScriptManager>
        <div>
            <telerik:RadComboBox ID="RadComboBox1" runat="server" RenderMode="Lightweight"
                OnClientSelectedIndexChanged="OnClientSelectedIndexChanged">
                <Items>
                    <telerik:RadComboBoxItem runat="server" Text="Item1" Value="Item1" />
                    <telerik:RadComboBoxItem runat="server" Text="Item2" Value="Item2" />
                </Items>
            </telerik:RadComboBox>
        </div>
    </form>
    <script>
        function pageLoad() {
            var combo = $find("<%= RadComboBox1.ClientID  %>");
            var item = combo.get_items().getItem(0);
            item.select();
        }
     
        function OnClientSelectedIndexChanged(sender, args) {
            alert("SelectedIndexChanged fired from pageLoad");
        }
    </script>


    Regards,
    Anton
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top