How to get selecteditem of radcombo thru javascript

6 posts, 0 answers
  1. Naresh
    Naresh avatar
    22 posts
    Member since:
    Oct 2010

    Posted 30 May 2011 Link to this post

    Team,
     I have rad combo with three item:Rice,wheat and Sugar
    I wan to get the selected item of this combo in java script.please share me the code snippet
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 31 May 2011 Link to this post

    Hello Naresh,

    Try the following code by attaching OnClientSelectedIndexChanged event. Hope this helps you.

    aspx:
    <telerik:RadComboBox ID="Combo" runat="server" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" >
       <Items>
                <telerik:RadComboBoxItem Text="Rice" Value="1" />
                <telerik:RadComboBoxItem Text="Wheat" Value="2" />
                <telerik:RadComboBoxItem Text="Sugar" Value="3" />
       </Items>
    </telerik:RadComboBox>

    Javascript:
    <script type="text/javascript">
        function OnClientSelectedIndexChanged(sender, args)
        {
            alert(args.get_item().get_text());
        }
    </script>


    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Naresh
    Naresh avatar
    22 posts
    Member since:
    Oct 2010

    Posted 02 Jun 2011 Link to this post

    Princy ,
    Thanks for your time on this.My Query here is to get the selected Item text  not all the text.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Jun 2011 Link to this post

    Hello Naresh,

     The RadControls accepts two parameters as its arguments, sender and arguments. In SelectedIndexChanged event (client side) you can directly access the seleced text via "args.get_item().get_text()". You can also access the item using sender as shown below.

    Javascript:
      function OnClientSelectedIndexChanged(sender, args)
     {
     var combo = sender;
    alert(combo.get_selectedItem().get_text());
     }

    Check the following help article which explains more about this.
    Client-Side Basics.

    Thanks,
    Princy.
  6. Mujeeb
    Mujeeb avatar
    6 posts
    Member since:
    May 2014

    Posted 09 May 2014 in reply to Princy Link to this post

    Hi Team Telerik,

    I have two rad combo box in the ASP.NET Ajax web form.

    Depending on the first radcombobox value, i need to make the second radcombobox selected.

    How can we do this programatically?

    Thank You and Kind Regards
    Mujeeb
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 May 2014 in reply to Mujeeb Link to this post

    Hi Mujeeb,

    Please have a look into this online demo which deals the same scenario.

    Thanks,
    Princy.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017