0
我有多个自动完成文本框与多个隐藏字段配对。我怎么做?防爆。 textbox1:name = hiddenfield1:Id,textbox2:name = hiddenfield2:Id。 我已经能够做1自动完成和1隐藏字段的工作。如何在jQuery UI中为多个自动填充文本框和隐藏字段分配一个值?
这里是我的脚本代码:
<script type="text/javascript">
$(document).ready(function() {
$('.auto').autocomplete({
source: "search.php",
focus: function(event, ui) {
$(idField).val(ui.item.value);
$(this).val(ui.item.label);
return false;
},
select: function(event, ui) {
$(this).val(ui.item.label);
$("#hidden").val(ui.item.value);
return false;
}
//minLength: 3
});
});
</script>
<p>Type the name of a band: <input type="text" class="auto" /></p>
<p>Type the name of a band: <input type="text" class="auto" /></p>
<input name="hidden" id="hidden" type="hidden" />
<input name="hidden" id="hidden" type="hidden" />
先生/女士你的答案会有很大的帮助,非常感谢。
我试过了,但由于某些原因,它不工作,它不能将值放在隐藏字段中。 – 2012-02-07 16:44:38
它终于奏效了。这里是脚本:select:function(event,ui){// {(this)this.val (ui.item.label);} $(this).val(ui.item.label); \t \t var a =“#”+ $(this).attr('id'); \t \t $(a +“hidden”).val(ui.item.value); 返回false; – 2012-02-07 17:43:22
太棒了,很高兴你来到了正确的位置......在你的脚本上面看起来'_'可能被遗漏了,但是如果它工作的太好了! – 2012-02-08 07:04:11