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

[Solved] Accessing the value of a combobox

1 Answer 130 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jack Helm
Top achievements
Rank 1
Jack Helm asked on 29 Jan 2010, 03:29 PM
I am trying to figure out how to access the value of the selected item in a combo box on the client side. I am trying to do this from inside another javascript function where I am building an array of the information on the screen.

All of the examples I have found so far show assigning the value during an event firing. I need to find the value outside of one fo the combobox events firing. If I were using an HTML dropdown I wold just ask for the control.value. But when I try that with the telerik control I get the text of the selected item rather than the assigned value of the selected item. I have been unsuccessful in figuring this out from the help file. Can someone point me to a place that explains how to do this simple task?

1 Answer, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 29 Jan 2010, 03:48 PM
The following worked for me:

<html xmlns="http://www.w3.org/1999/xhtml"
<head id="Head1" runat="server"
    <title>Test</title> 
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
        <script type="text/javascript"
            function OnLoad(sender, args) { 
                var comboBox = sender
                var itemValue = comboBox.get_value(); 
                alert(itemValue); 
            } 
        </script> 
        </telerik:RadCodeBlock> 
</head> 
<body> 
    <form id="form1" runat="server"
        <div> 
            <asp:ScriptManager ID="ScriptManager" runat="server"
            </asp:ScriptManager> 
            <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="160px" OnClientLoad="OnLoad"
                <Items> 
                    <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1"  
                        Value="myItemValue" /> 
                </Items> 
            </telerik:RadComboBox> 
        </div> 
    </form> 
</body> 
</html> 

I think what you were looking for was the get_value() function that is offered on the client-side. You can get more information on other functions to use on a RadComboBox object by looking into this documentation article :)



Tags
ComboBox
Asked by
Jack Helm
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Share this question
or