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

How to get the text contents (box value) of AutoCompleteBox?

1 Answer 140 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Yan Moura asked on 15 Jan 2021, 03:23 PM
Hi, I need to retrieve the text contents of AutoCompleteBox in Javascript (client side).
I tried this but it just alerts me nothing (blank result):
<script>
function CheckOE() {
            alert(document.getElementById('RadAutoCompleteBox1').value);
        }
</script>
<telerik:RadAutoCompleteBox RenderMode="Lightweight" runat="server" ID="RadAutoCompleteBox1" ClientID="RadAutoCompleteBox1" 
            autopostback="true"
            DataSourceID="blah" DataTextField="blah" DataValueField="blah" InputType="blah" Width="100%"
            AllowCustomEntry = "false"
            DropDownWidth="150px"
            onfocusout="CheckOE()"
            >
Any idea?
Thanks!

1 Answer, 1 is accepted

Sort by
0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 18 Jan 2021, 06:34 PM

I figured it out by myself in case someone be interested:

<telerik:RadAutoCompleteBox RenderMode="Lightweight" runat="server" ID="RadAutoCompleteBox1" ClientID="RadAutoCompleteBox1" 
            autopostback="true"
            DataSourceID="yourdata" DataTextField="yourdata" DataValueField="yourdata"
            InputType="Token" Width="100%" Visible="true"
            AllowCustomEntry = "true"
            DropDownWidth="150px"
            OnEntryAdded="RadAutoCompleteBox1_EntryAdded"
            OnEntryRemoved="RadAutoCompleteBox1_EntryRemoved"
            OnClientLoad="OnClientLoad"
            >
        </telerik:RadAutoCompleteBox>

<

<script>
$telerik.$(sender.get_inputElement()).on('keyup', function (e) {
                // get contents of the input text
                var autoComplete = $find("<%= RadAutoCompleteBox1.ClientID %>");
                var contents = autoComplete.get_inputElement();
                alert(contents.value);
            });
</script>

Tags
AutoCompleteBox
Asked by
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Answers by
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Share this question
or