JavaScript RadComboBox SelectedValue

5 posts, 0 answers
  1. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 16 Jul 2010 Link to this post

    I want to obtain via Javascript the SelectedValue of a RadComboBox but it seem not possible.
    My goal is to change (clientside) RadComboBox1 selectedvalue, starting from another javascript event.

    Here you can find the example page:

    <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderBody" runat="Server">
        <script type="text/javascript">  
            function getvalue()  
            {
                var combo = <%=RadComboBox1.ClientID %>;
                alert(combo.SelectedItem);
                alert( document.getElementById(combo.UniqueID + "_value").value );
            }  
        </script>
        <telerik:RadComboBox ID="RadComboBox1" runat="server">
            <Items>
                <telerik:RadComboBoxItem Text="Item1" Value="Value1" />
                <telerik:RadComboBoxItem Text="Item2" Value="Value2" />
                <telerik:RadComboBoxItem Text="Item3" Value="Value3" />
            </Items>
        </telerik:RadComboBox>
        <input id="Button1" type="button" value="button" onclick="getvalue();" />
    </asp:Content>

    Anyone can help?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Jul 2010 Link to this post

    Hello,

    You could use the $find() method to get reference to AJAX control's client object.

    Here is the sample code:
    <script type="text/javascript"
        function getvalue() 
        {
            var combo = $find('<%=RadComboBox1.ClientID %>');
            alert(combo.get_selectedItem().get_value());
        
    </script>


    And for more information about client methods of RadComboBox, go through the links below:
    RadComboBox object
    RadComboBoxItemCollection object


    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jehad
    Jehad avatar
    1 posts
    Member since:
    Sep 2012

    Posted 09 Sep 2012 Link to this post


    telerik RadComboBox  :: Get Selected value by js



    function getSelectedValue() {

     var ddlCurrency = document.getElementById('ddlCurrencyID');

     var selectedValue = ddlCurrency.control._value;

     var selectedText =  ddlCurrency.control._text;

    }

  5. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 10 Sep 2012 Link to this post

    Hello,

    Considering we aim to get the value of an Ajax Control, the better approach is to access the client instance of the control with $find() instead of accessing the DOM element with document.getElementById(). Please consider implementing the approach that Shinu has proposed.
     
    Kind regards,
    Nencho
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Rajeeve
    Rajeeve avatar
    3 posts
    Member since:
    Aug 2016

    Posted 11 Aug Link to this post

    var checkeditems;
    var combo = $find("<%= telerikcomboboxname.ClientID%>")
     var items = combo.get_checkedItems();
      for (i = 0; i < items.length; i++) {

                            if (i == 0) {
                                radvalue = Number(parseInt(items[i]._properties._data.value));
                               checkeditems=checkeditems+radvalue ;
                            }
                            else {
                                radvalue = Number(parseInt(items[i]._properties._data.value));
                                checkeditems= checkeditems+ "," + radvalue;
                            }

                   }
                        alert(Expenseitems);
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017