如何删除文本框上的自动建议功能
我有一个文本框,我想根据单选按钮选项加载 2 自动建议
意味着如果用户选择选项按钮 1,则自动建议应加载产品员工表。如果用户选择选项按钮 2,则自动建议应加载自定义产品表。
我正在使用 jquery auto suggest
我怎样才能实现这种功能
示例 当我选择单选按钮 SetAutoSuggest 方法将被调用
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
}
);
}
}
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
}
);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将点击事件分配给复选框,并根据选中的复选框更改您的 URL。
或者,您可以在自动完成源上使用回调函数,该函数将验证选中了哪个复选框并提取正确的源 URL。
使用回调函数时遇到的最大问题是它需要非常严格的格式:
响应应该采用以下格式:
使用单选按钮来代替您想要执行的操作不是更好吗?
这听起来像是您试图执行非此即彼而不是多选项(复选框)的情况。
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:
Response should be in this format:
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).