当我在一个页面中使用这两次时,Jquery自动完成功能无法正常工作 [英] Jquery autocomplete not working when I use this two times in one page
问题描述
嗨
当我在页面中使用jquery自动完成功能时它运行良好。现在我有一个页面有两个field.one用于搜索主题,另一个用于搜索研究所。当我在两个字段中使用jquery自动完成时它只能工作。只有第一个野外工作第二个字段无法工作。我的代码如下:
< script 类型 = text / javascript > ;
$( # + fieldID + )。autocomplete({
source: function (请求,响应){
$ .ajax({
url: auto comp3.asp,
dataType: json,
数据:{
term:request.term
},
成功: function (数据){
响应(数据);
}
});
},
minLength: 3 ,
延迟: 300 ,
select: function (event,ui){
// $( #txtAllowSearch)VAL(ui.item.label)。 //显示所选文本
$( # + hiddenIdField + < span class =code-string> )。val(ui.item.id); // 将所选内容保存到隐藏输入
}
});
< / script >
< script type = text / javascript >
var fieldID = ;
function SetParam(fID)
{
fieldID = fID;
}
< / script >
< 输入 type = text id = subject >
< input 类型 = text id = 学院 >
plz帮我解决这个问题
我尝试过:
i使用这个
< input type =textid =subject>
< input type = textid =institute>
onclick()设置id动态
( # + fieldID + < span class =code-string>)。autocomplete({
source: function (request,response){
.ajax({
url: autocomp3.asp ,
dataType: json,
data:{
term:request.term
},
成功:功能(数据){
响应(数据);
}
});
},
minLength: 3 ,
延迟: 300 ,
select: function (event,ui){
//
( #txtAllowSearch)VAL(ui.item.label)。 //显示所选文本
Hi
when i use jquery autocomplete in a page its working well.Now i have a page which have two field.one is for searching subject and another is for searching institute.When i use jquery autocomplete in both fields it can not work.only first field work second field can not work.My code is given below:
<script type="text/javascript">
$("#"+fieldID+"").autocomplete({
source: function(request, response) {
$.ajax({
url: "autocomp3.asp",
dataType: "json",
data: {
term : request.term
},
success: function(data) {
response(data);
}
});
},
minLength: 3,
delay: 300,
select: function (event, ui) {
//$("#txtAllowSearch").val(ui.item.label); // display the selected text
$("#"+hiddenIdField+"").val(ui.item.id); // save selected id to hidden input
}
});
</script>
<script type="text/javascript">
var fieldID ="";
function SetParam(fID)
{
fieldID = fID;
}
</script>
<input type="text" id="subject" >
<input type="text" id="institute" >
plz help me how to solve this problem
What I have tried:
i use this
<input type="text" id="subject" >
<input type="text" id="institute" >
onclick() to set the id dynamic
("#"+fieldID+"").autocomplete({ source: function(request, response) {
.ajax({ url: "autocomp3.asp", dataType: "json", data: { term : request.term }, success: function(data) { response(data); } }); }, minLength: 3, delay: 300, select: function (event, ui) { //
("#txtAllowSearch").val(ui.item.label); // display the selected text
这篇关于当我在一个页面中使用这两次时,Jquery自动完成功能无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!