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

Clear value in javascript

1 Answer 156 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 01 Mar 2013, 03:55 PM
Hello,

I have an AutoCompleteBox and am trying to clear the client-side value using a javascript function.

I have given an example below with a comment at where I am unsure of what property to use. When the button is clicked any user inputted text should be cleared and the EmptyMessage appears.

function ClearBox()
{
    var box = $("#<%= ctrlBox.ClientID %>");
    //what do I put here to clear the value??
    //I tried box.text('') but it doesn't work
}
 
<input type='button' onclick='ClearBox();' />
<telerik:RadAutoCompleteBox ID="ctrlBox"
       runat="server"
       InputType="Text"
       AllowCustomEntry="false"
       Filter="Contains"
       Delimiter=" "
       Width="630px"
       DropDownWidth="660px"
       EmptyMessage="Type here"
       OnClientDropDownOpening="openingDropdown"
       OnClientLoad="loadingAutoComplete"
       OnClientRequesting="requesting" >
</telerik:RadAutoCompleteBox>

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Mar 2013, 05:43 AM
Hi,

Try the following javascript.
JS:
function ClearBox() {
        debugger;
        var autoCompleteBox = $find("<%=ctrlBox.ClientID %>");
        var firstEntry = autoCompleteBox.get_entries().getEntry(0);
        if (firstEntry) {
            autoCompleteBox.get_entries().remove(firstEntry);
        }
}

Thanks,
Princy
Tags
AutoCompleteBox
Asked by
Dan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or