开发者

JQuery Auto-complete on dynamic form elements?

开发者 https://www.devze.com 2023-02-22 16:56 出处:网络
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.

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 littl开发者_开发问答e better.

Thank you for any help.

Martin


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
});
0

精彩评论

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