繁体   English   中英

在onfocus上获取另一个值并调用tokeninput

[英]get another value when onfocus and call tokeninput

我正在使用詹姆斯·史密斯(James Smith)的令牌输入,即使在我同时调用令牌输入的情况下,也无法获得重点关注的值。 我需要该值来获取查询并将查询结果作为令牌列表返回。

  loadTokenInput2('txtunit',params,'Kode Unit', 60) 

我用此功能调用了令牌输入:

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将是错误的(我使用了子句查询)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM