简体   繁体   中英

How to set value to telerik:RadAutoCompleteBox from javascript?

I am using telerik:RadAutoCompleteBox as a input element.I want to set its value from javascript on the click event of the another button.The code for the element is as follows:

<telerik:RadAutoCompleteBox
         runat="server"
         ID="costCodeTxt"
         Width="400"
         OnClientRequesting="requesting"
         DropDownWidth="300"
         InputType="Text"
         TextSettings-SelectionMode="Single"
         OnClientTextChanged="VerifyJobCostCode">
               <WebServiceSettings Path="~/QuantitySurvey/CostCode.asmx" Method="GetCostCodeList" />
</telerik:RadAutoCompleteBox>

This should work to get you to the dom element, allowing you to set the value.

function setText(text){
    var domElement = $find("<%= costCodeTxt.ClientID %>").get_inputElement();
    domElement.value = text;
}

You probably also want to set this to allow custom text

AllowCustomEntry = "true"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM