我正在使用James smith的令牌输入,即使因为我同时调用令牌输入,我在获得焦点值时也遇到了问题。我需要该值来获取查询并将查询结果作为标记列表返回。
loadTokenInput2('txtunit',params,'Kode Unit', 60)
答案 0 :(得分:0)
我用这个函数调用了令牌输入:
function loadTokenInput2(objtext,url,hinttext,widthtoken)
{
if(!hinttext){hinttext="Type key in this text box";}
if(!widthtoken){widthtoken=400;}
$('#'+objtext).tokenInput(url,
{
tokenLimit :1,hintText: hinttext,tokenwidth:widthtoken,
propertyToSearch: "id",
resultsFormatter:function(item)
{
return "<li>" + "<div style='display: inline-block;'><table><tr><td><div class='id'>" + item.id + "</div></td><td><div class='name'>" + item.name + "</div></td></tr></table></div></li>" },
tokenFormatter: function(item) { return "<li><p>" + item.id + "</p></li>"}
});
}
我输入文字如下:
<input type=\"text\" id=\"txtlocation\" style=\"width:60px;\" onFocus=\"loadTokenInput2('txtlocation',$url,'Kode Location',60)\" onchange=\"$eventchange\" />
下面有$eventchange
:
$eventchange="$('#txtunit').focus(function(){";
$eventchange.=" var params='index.php?ajax=1&option=com_fpbjrefusr&task=tokeninput_searchbudgetacc&q='+txtunit.value+'&typeacc=unit&fields=unitcode,description';";
$eventchange.=" params=params+'&swhere='+txtlocation.value;";
$eventchange.=" loadTokenInput2('txtunit',params,'Kode Unit', 60);";
$eventchange.="})";
所以当输入类型改变时,将onfocus
函数调用此输入类型并在tokeninput_searchbudgetacc
中加载基于令牌输入结果的查询:
<input type=\"text\" id=\"txtunit\" style=\"width:60px;\" />
我得到的是txtlocation.value
仍未改变输入类型txtlocation
用户更改了值。它导致返回值为token list
来自查询将是错误的(我使用了子句查询)。