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

How to get selecteditem of radcombo thru javascript

5 Answers 599 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Naresh
Top achievements
Rank 1
Naresh asked on 30 May 2011, 04:46 PM
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

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 May 2011, 07:11 AM
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.
0
Naresh
Top achievements
Rank 1
answered on 02 Jun 2011, 12:04 PM
Princy ,
Thanks for your time on this.My Query here is to get the selected Item text  not all the text.
0
Princy
Top achievements
Rank 2
answered on 02 Jun 2011, 02:05 PM
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.
0
Mujeeb
Top achievements
Rank 1
answered on 10 May 2014, 12:34 AM
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
0
Princy
Top achievements
Rank 2
answered on 12 May 2014, 04:10 AM
Hi Mujeeb,

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

Thanks,
Princy.
Tags
ComboBox
Asked by
Naresh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Naresh
Top achievements
Rank 1
Mujeeb
Top achievements
Rank 1
Share this question
or