简体   繁体   English

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

[英]get another value when onfocus and call tokeninput

I am using token input by James smith, I have a problem while getting value with on focus even because of I call token input at the same time. 我正在使用詹姆斯·史密斯(James Smith)的令牌输入,即使在我同时调用令牌输入的情况下,也无法获得重点关注的值。 I need that value to get query and return result of query as the token list. 我需要该值来获取查询并将查询结果作为令牌列表返回。

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

i called token input with this function : 我用此功能调用了令牌输入:

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>"}
            });

    }

i make input text as below : 我将输入文本如下:

<input type=\"text\" id=\"txtlocation\" style=\"width:60px;\" onFocus=\"loadTokenInput2('txtlocation',$url,'Kode Location',60)\" onchange=\"$eventchange\" />

with $eventchange below: 以下是$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.="})";

so when that input type change, will call onfocus function to this input type and load token input result based query in tokeninput_searchbudgetacc : 因此,当输入类型更改时,将调用onfocus函数对此输入类型进行加载,并在tokeninput_searchbudgetacc加载基于令牌输入结果的查询:

<input type=\"text\" id=\"txtunit\" style=\"width:60px;\" />

what i got is txtlocation.value still not changed where input type txtlocation 我得到的是txtlocation.value仍然不改变输入类型txtlocation

value changed by user. 用户更改的值。 it caused the return value as token list from query will be fault (i used clause query). 它导致返回值作为查询的token list将是错误的(我使用了子句查询)。

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

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