Javascript UI使用jquery自动完成多个组合框
我这里有一个问题,我是jquery自动完成组合框的新手 这里我们动态添加组合框。我的自动完成功能在所有组合框中都可以正常工作,但当我再次返回该页面时,我无法保留页面上的值 下面是示例代码Javascript UI使用jquery自动完成多个组合框,javascript,jquery,combobox,autocomplete,el,Javascript,Jquery,Combobox,Autocomplete,El,我这里有一个问题,我是jquery自动完成组合框的新手 这里我们动态添加组合框。我的自动完成功能在所有组合框中都可以正常工作,但当我再次返回该页面时,我无法保留页面上的值 下面是示例代码 _createAutocomplete: function() { var selected = this.element.children(":selected"); var value = selected.val() ? selected.tex
_createAutocomplete: function() {
var selected = this.element.children(":selected");
var value = selected.val() ? selected.text() : "";
var x = this.element[0].id; //we get id's of combo boxes like Comobox-0,Comobox-1,Comobox-2...etc
var status = x.substr(x.length - 1); // The values will be like 0,1,2 .. in strings etc
var istatus = parseInt(status); // parsing to int
this.input = $( "<input>" )
.appendTo( this.wrapper )
.attr( "title", '<fmt:message key="page.claim.personalclaimnotification.injury.select_info" />' )
<%--.val("${claimNotificationForm.chattels[ss].objectValue}") --%>
.val(value) // This is responsible for retaining the values on the page
.attr("maxlength", 256)
.addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
.autocomplete({
delay: 0,
minLength: 3,
source: $.proxy( this, "_source" )
})
这里我的要求是,如果列表中不存在用户给定的值,那么该值将作为一个值。
所以我试图保留表单bean中的值
var x = this.element[0].id; //we get id's of combo boxes like Comobox-0,Comobox-1,Comobox-2...etc
var status = x.substr(x.length - 1); // The values will be like 0,1,2 .. in strings etc
var istatus = parseInt(status); // parsing to int
然后,我使用下面的方法动态地从集合中选取值,但这不起作用
.val("${claimNotificationForm.chattels[istatus].objectValue}")
上面的代码正在使用索引0,1,2。。但不是用变量istatus
.val("${claimNotificationForm.chattels[0].objectValue}")
.val("${claimNotificationForm.chattels[1].objectValue}")
.val("${claimNotificationForm.chattels[2].objectValue}")
我如何使它工作,以便它使用jsp中的el表达式动态地从表单bean中选择
.val("${claimNotificationForm.chattels[0].objectValue}")
.val("${claimNotificationForm.chattels[1].objectValue}")
.val("${claimNotificationForm.chattels[2].objectValue}")