开发者

How to remove auto suggest functionality on Textbox

I have one text box and i want load 2 auto suggest basis on radio button option

Means if user select option button 1 then auto suggest should load Product employee table.if User select option button 2 then auto suggest should load Custom Product table.

I am using jquery auto suggest

How could i achieve this kind of functionality

Example for when开发者_如何转开发 i select radio button SetAutoSuggest Method Will be called

   function SetAutoSuggest(ProductType) {

    if (ProductType == "PRODUCT") {

        $("#PantryFooodItemName").autocomplete('<%= Url.Action("GetAutosuggestProductlistForMeal", "Autosuggest") %>',
            {
                minChars: 2,
                width: 300,
                multiple: false,
                matchContains: true,
                mustMatch:true,
                formatItem: formatItem,
                formatResult: formatResult
            }
            );





}
if (ProductType == "CUSTOMPRODUCT") {
    $("#PantryFooodItemName").autocomplete('<%= Url.Action("GetCustomProduct", "Autosuggest") %>',
            {
                minChars: 2,
                width: 300,
                multiple: false,
                matchContains: true,
                mustMatch: true,
                formatItem: formatItem,
                formatResult: formatResult
            }
            );

}
    }


Assign click events to the checkboxes and change your URL based on which one is checked.

Alternatively, you can use a callback function on the autocomplete source which would verify which checkbox is checked and pull the proper source url. The biggest thing you'll run into using the callback function is it requires a very strict format:

source: function(request, response)
{}

Response should be in this format:

[{"id":25,"label":"mylabel","value":"myval"},{"id":26,"label":"mylabel26","value":"myval26"}]

Wouldn't it be better to use a radio button for what you're trying to do instead? It sounds like a situation where you're trying to do an either/or and not a multi-option (checkboxes).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜