jQuery javascript 自动完成和管理 ids

发布于 2025-01-04 22:55:37 字数 457 浏览 3 评论 0原文

我正在使用 jQuery UI 自动完成,现在在隐藏字段中我试图管理所选项目,

例如,考虑这是我拥有的数据集,[Apple:1, Mango:2, Coconut:3, Apple:4]

现在,如果我输入 hello 它应该打印 hello 现在到隐藏字段如果我触发自动完成并从隐藏字段中选择 Apple 应该是 hello [Apple:1]

到目前为止一切都很好,但是如果我从 applee > 主文本框中的隐藏字段应包含 hello appl ,它还应该允许有多个具有相同名称的条目(如此处所示,有 2 个 apple 条目)

I am using jQuery UI autocomplete, Now in the hidden field I am trying to manage the ids of the item selected,

For example, consider this is the data set I have, [Apple:1, Mango:2, Coconut:3, Apple:4]

Now if I type hello it should print hello to hidden field now if I trigger autocomplete and select Apple from it hidden field should be hello [Apple:1]

So far all good, but if I delete e from apple from the main textbox hidden field should hold
hello appl , It should also allow to have multiple entries with same name (as shown here with 2 entries of apple)

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

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

发布评论

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

评论(1

随心而道 2025-01-11 22:55:37

我使用地图数据结构管理它,因此如果我选择 abc 我会将其添加到地图 {abc, 1} 现在更改时我将按空格分割它,我看到如果该单词属于映射,如果是,则将其替换为它的值

I managed it with a map data structure so if I select abc I will add it into map {abc, 1} now on change I am splitting it by space and I see if the word belongs to map if yes then replace it with its value

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