JQuery 在动态表单元素上自动完成?

发布于 2024-10-30 11:46:06 字数 485 浏览 4 评论 0原文

可能最容易在这个小提琴上看到:

http://jsfiddle.net/pjQVJ/

如果您选择 escherpropname 在第一个下拉列表中,第三个下拉列表被文本框输入替换。

我想对这些文本框应用自动完成插件,但它可以选择的值取决于第一个下拉列表的选定值。

这里的代码看起来很简单: http://jqueryui.com/demos/autocomplete/ 和那么我只需要以某种方式将文本框的 id 设置为下拉列表中选定的值,以便它只能从该特定数组中选择值 - 如果这有意义吗?

如果有任何困惑,请告诉我,我会尽力更好地解释自己。

感谢您的帮助。

马丁

Probably easiest to see on this fiddle:

http://jsfiddle.net/pjQVJ/

If you select escherpropname in the first drop-down, the third drop-down is replaced by a text box input.

I would like to apply an auto-complete plugin to these text boxes but the values it can choose from to be dependant on the the selected value of the first-drop down.

The code here looks straight-forward enough: http://jqueryui.com/demos/autocomplete/ and then I only need to somehow set the id of the text-box to the selected value of the drop-down so that it can only choose values from that particular array - if that makes sense?

If there is any confusion let me know and I will try and explain myself a little better.

Thank you for any help.

Martin

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

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

发布评论

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

评论(1

自演自醉 2024-11-06 11:46:06

我不知道你在做什么,但它似乎可以这个方式工作。

var input = $('<input></input>').appendTo($('#div'));
var availableTags = [
            "ActionScript",
            "AppleScript",
            "Asp",
            "BASIC",
            "C",
            "C++",
            "Clojure",
            "COBOL",
            "ColdFusion",
            "Erlang",
            "Fortran",
            "Groovy",
            "Haskell",
            "Java",
            "JavaScript",
            "Lisp",
            "Perl",
            "PHP",
            "Python",
            "Ruby",
            "Scala",
            "Scheme"
        ];
$(input).autocomplete({
       source: availableTags
});

I don't how you are doing but it seems to work THIS way.

var input = $('<input></input>').appendTo($('#div'));
var availableTags = [
            "ActionScript",
            "AppleScript",
            "Asp",
            "BASIC",
            "C",
            "C++",
            "Clojure",
            "COBOL",
            "ColdFusion",
            "Erlang",
            "Fortran",
            "Groovy",
            "Haskell",
            "Java",
            "JavaScript",
            "Lisp",
            "Perl",
            "PHP",
            "Python",
            "Ruby",
            "Scala",
            "Scheme"
        ];
$(input).autocomplete({
       source: availableTags
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文