如何从 jquery-autocomplete 检索两个值

发布于 2024-09-06 11:43:13 字数 173 浏览 2 评论 0原文

我需要我的申请自动填写公司名称,但也需要使用所选公司的 ID 填写隐藏的表单字段。

我相信可以使用管道分隔符返回对值,例如......

Microsoft|10
Oracle|20
Sybase|30

确实这似乎有效,但我不知道如何访问第二个参数。

I need my application to auto-complete on a company name, but also fill in a hidden form field with the ID of that company selected.

I believe it's possible to return pair values, with the pipe separator, such as........

Microsoft|10
Oracle|20
Sybase|30

And indeed this seems to work, but I don't know how to access the 2nd argument.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只怪假的太真实 2024-09-13 11:43:15

所有内容都应该在您的 select 函数中返回。您的选择函数应与此类似:

function autoCompleteSelected(event, item, formatted) 
{
   item[0]; // Should be Microsoft
   item[1]; // Should be 10;
}

然后指定选择函数:

$("#autoCompleteField").autocomplete(url).result("autoCompleteSelected");

Everything should be returned within your select function. Your select function should be similar to this:

function autoCompleteSelected(event, item, formatted) 
{
   item[0]; // Should be Microsoft
   item[1]; // Should be 10;
}

Then to specify the select function:

$("#autoCompleteField").autocomplete(url).result("autoCompleteSelected");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文