Ok, ya lo terminé, efectivamente hice un array con los datos de la consulta y luego los paso a js, uso un conjunto de funciones js muy bien escritas que encontré y le adapté un script que genera nuevos inputs.<br>Todo es para cargar ítems en una factura determinada.<br>
<br>Para los que alguna vez necesiten un autocompletar lo paso por acá, aunque pueda haber mejores este me pareció simple y liviano.<br><br>&lt;?php<br>//Funcion que convierte un array php en un array js<br>function php2js ($var) {<br>
<br>    if (is_array($var)) {<br>        $res = &quot;[&quot;;<br>        $array = array();<br>        foreach ($var as $a_var) {<br>            $array[] = php2js(trim($a_var));<br>        }<br>        return &quot;[&quot; . join(&quot;,&quot;, $array) . &quot;]&quot;;<br>
    }<br>    elseif (is_bool($var)) {<br>        return $var ? &quot;true&quot; : &quot;false&quot;;<br>    }<br>    elseif (is_int($var) || is_integer($var) || is_double($var) || is_float($var)) {<br>        return $var;<br>
    }<br>    elseif (is_string($var)) {<br>        return &quot;\&quot;&quot; . addslashes(stripslashes($var)) . &quot;\&quot;&quot;;<br>    }<br><br>    return FALSE;<br>}<br><br><b>ESTA SERÍA LA PARTE DE GENERAR LA CONSULTA Y PONERLA EN UN ARRAY</b><br>
<b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><br>
//init the SOAP Client<br>require(&quot;lib.php&quot;); //API CASPIO<br>$wsdl = &quot;<a href="https://b3.caspio.com/ws/api.asmx?wsdl">https://b3.caspio.com/ws/api.asmx?wsdl</a>&quot;;<br>$client = new SoapClient($wsdl);<br>
<br>//Armo el array con la consulta de los productos<br>$php_array = $client-&gt;SelectDataRaw(&quot;silveral&quot;, &quot;administracion&quot;, &quot;1kE9u58vu82HircT5&quot;, &quot;Productos_visibles&quot;,<br>true, <br>
&quot;Productos_Codigo, Productos_Descripcion&quot;,<br>&quot;Productos_Codigo IS NOT NULL&quot;,<br>&quot;Productos_Codigo ASC&quot;,<br>&quot; - &quot;, &quot; &quot;);<b><br></b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//</b><b>//<br>
<br></b>//Convierto el array php en array js<br>$js_array = php2js($php_array);<br>?&gt;<br><br>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>&quot;&gt;<br>
&lt;html xmlns=&quot;<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>&quot;&gt;<br>&lt;title&gt;Carga Item Factura&lt;/title&gt;<br>&lt;head&gt;<br>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;<br>
&lt;script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;&gt;<br>function autoCompleteDB()<br>{<br>    this.aNames=new Array();<br>}<br><br>autoCompleteDB.prototype.assignArray=function(aList)<br>{<br>    this.aNames=aList;<br>
};<br><br>autoCompleteDB.prototype.getMatches=function(str,aList,maxSize)<br>{<br>    /* debug */ //alert(maxSize+&quot;ok getmatches&quot;);<br>    var ctr=0;<br>    for(var i in this.aNames)<br>    {<br>        if(this.aNames[i].toLowerCase().indexOf(str.toLowerCase())==0) /*looking for case insensitive matches */<br>
        {<br>            aList.push(this.aNames[i]);<br>            ctr++;<br>        }<br>        if(ctr==(maxSize-1)) /* counter to limit no of matches to maxSize */<br>            break;<br>    }<br>};<br><br>function autoComplete(aNames,oText,oDiv,maxSize)<br>
{<br><br>    this.oText=oText;<br>    this.oDiv=oDiv;<br>    this.maxSize=maxSize;<br>    this.cur=-1;<br><br>    <br>    /*debug here */<br>    //alert(oText+&quot;,&quot;+this.oDiv);<br>    <br>    this.db=new autoCompleteDB();<br>
    this.db.assignArray(aNames);<br>    <br>    oText.onkeyup=this.keyUp;<br>    oText.onkeydown=this.keyDown;<br>    oText.autoComplete=this;<br>    oText.onblur=this.hideSuggest;<br>}<br><br>autoComplete.prototype.hideSuggest=function()<br>
{<br>    this.autoComplete.oDiv.style.visibility=&quot;hidden&quot;;<br>};<br><br>autoComplete.prototype.selectText=function(iStart,iEnd)<br>{<br>    if(this.oText.createTextRange) /* For IE */<br>    {<br>        var oRange=this.oText.createTextRange();<br>
        oRange.moveStart(&quot;character&quot;,iStart);<br>        oRange.moveEnd(&quot;character&quot;,iEnd-this.oText.value.length);<br>        oRange.select();<br>    }<br>    else if(this.oText.setSelectionRange) /* For Mozilla */<br>
    {<br>        this.oText.setSelectionRange(iStart,iEnd);<br>    }<br>    this.oText.focus();<br>};<br><br>autoComplete.prototype.textComplete=function(sFirstMatch)<br>{<br>    if(this.oText.createTextRange || this.oText.setSelectionRange)<br>
    {<br>        var iStart=this.oText.value.length;<br>        this.oText.value=sFirstMatch;<br>        this.selectText(iStart,sFirstMatch.length);<br>    }<br>};<br><br>autoComplete.prototype.keyDown=function(oEvent)<br>
{<br>    oEvent=window.event || oEvent;<br>    iKeyCode=oEvent.keyCode;<br><br>    switch(iKeyCode)<br>    {<br>        case 38: //up arrow<br>            this.autoComplete.moveUp();<br>            break;<br>        case 40: //down arrow<br>
            this.autoComplete.moveDown();<br>            break;<br>        case 13: //return key<br>            window.focus();<br>            break;<br>    }<br>};<br><br>autoComplete.prototype.moveDown=function()<br>{<br>
    if(this.oDiv.childNodes.length&gt;0 &amp;&amp; this.cur&lt;(this.oDiv.childNodes.length-1))<br>    {<br>        ++this.cur;<br>        for(var i=0;i&lt;this.oDiv.childNodes.length;i++)<br>        {<br>            if(i==this.cur)<br>
            {<br>                this.oDiv.childNodes[i].className=&quot;over&quot;;<br>                this.oText.value=this.oDiv.childNodes[i].innerHTML;<br>            }<br>            else<br>            {<br>                this.oDiv.childNodes[i].className=&quot;&quot;;<br>
            }<br>        }<br>    }<br>};<br><br>autoComplete.prototype.moveUp=function()<br>{<br>    if(this.oDiv.childNodes.length&gt;0 &amp;&amp; this.cur&gt;0)<br>    {<br>        --this.cur;<br>        for(var i=0;i&lt;this.oDiv.childNodes.length;i++)<br>
        {<br>            if(i==this.cur)<br>            {<br>                this.oDiv.childNodes[i].className=&quot;over&quot;;<br>                this.oText.value=this.oDiv.childNodes[i].innerHTML;<br>            }<br>            else<br>
            {<br>                this.oDiv.childNodes[i].className=&quot;&quot;;<br>            }<br>        }<br>    }<br>};<br><br>autoComplete.prototype.keyUp=function(oEvent)<br>{<br>    oEvent=oEvent || window.event;<br>
    var iKeyCode=oEvent.keyCode;<br>    if(iKeyCode==8 || iKeyCode==46)<br>    {<br>        this.autoComplete.onTextChange(false); /* without autocomplete */<br>    }<br>    else if (iKeyCode &lt; 32 || (iKeyCode &gt;= 33 &amp;&amp; iKeyCode &lt;= 46) || (iKeyCode &gt;= 112 &amp;&amp; iKeyCode &lt;= 123)) <br>
    {<br>        //ignore<br>    } <br>    else <br>    {<br>        this.autoComplete.onTextChange(true); /* with autocomplete */<br>    }<br>};<br><br>autoComplete.prototype.positionSuggest=function() /* to calculate the appropriate poistion of the dropdown */<br>
{<br>    var oNode=this.oText;<br>    var x=0,y=oNode.offsetHeight;<br><br>    while(oNode.offsetParent &amp;&amp; oNode.offsetParent.tagName.toUpperCase() != &#39;BODY&#39;)<br>    {<br>        x+=oNode.offsetLeft;<br>        y+=oNode.offsetTop;<br>
        oNode=oNode.offsetParent;<br>    }<br><br>    x+=oNode.offsetLeft;<br>    y+=oNode.offsetTop;<br><br>    this.oDiv.style.top=y+&quot;px&quot;;<br>    this.oDiv.style.left=x+&quot;px&quot;;<br>}<br><br>autoComplete.prototype.onTextChange=function(bTextComplete)<br>
{<br>    var txt=this.oText.value;<br>    var oThis=this;<br>    this.cur=-1;<br>    <br>    if(txt.length&gt;0)<br>    {<br>        while(this.oDiv.hasChildNodes())<br>            this.oDiv.removeChild(this.oDiv.firstChild);<br>
        <br>        var aStr=new Array();<br>        this.db.getMatches(txt,aStr,this.maxSize);<br>        if(!aStr.length) {this.hideSuggest ;return}<br>        if(bTextComplete) this.textComplete(aStr[0]);<br>        this.positionSuggest();<br>
        <br>        for(i in aStr)<br>        {<br>            var oNew=document.createElement(&#39;div&#39;);<br>            this.oDiv.appendChild(oNew);<br>            oNew.onmouseover=<br>            oNew.onmouseout=<br>
            oNew.onmousedown=function(oEvent)<br>            {<br>                oEvent=window.event || oEvent;<br>                oSrcDiv=oEvent.target || oEvent.srcElement;<br><br>                //debug :window.status=oEvent.type;<br>
                if(oEvent.type==&quot;mousedown&quot;)<br>                {<br>                    oThis.oText.value=this.innerHTML;<br>                }<br>                else if(oEvent.type==&quot;mouseover&quot;)<br>                {<br>
                    this.className=&quot;over&quot;;<br>                }<br>                else if(oEvent.type==&quot;mouseout&quot;)<br>                {<br>                    this.className=&quot;&quot;;<br>                }<br>
                else<br>                {<br>                    this.oText.focus();<br>                }<br>            };<br>            oNew.innerHTML=aStr[i];<br>        }<br>        <br>        this.oDiv.style.visibility=&quot;visible&quot;;<br>
    }<br>    else<br>    {<br>        this.oDiv.innerHTML=&quot;&quot;;<br>        this.oDiv.style.visibility=&quot;hidden&quot;;<br>    }<br>};<br><br>/*function createAutoComplete()<br>{<br>    var aNames = &lt;?php //print_r($js_array); ?&gt;;<br>
    new autoComplete(aNames,document.getElementById(&#39;txt&#39;),document.getElementById(&#39;suggest&#39;),20);<br>}<br>*/<br>function createAutoComplete1(txt_input, suggest_div)<br>{<br>    var aNames = &lt;?php print_r($js_array); ?&gt;;<br>
    new autoComplete(aNames,document.getElementById(txt_input),document.getElementById(suggest_div),20);<br>}<br><br>/*&lt;![CDATA[*/<br>var c=1;<br>function newInput()<br>{<br>    //Create DIV<br>    var div = document.createElement(&#39;div&#39;);<br>
    <a href="http://div.id">div.id</a> = &quot;div_&quot; + c;<br>    document.f1.appendChild(div);<br>    //Input TEXT<br>    var inpt = document.createElement(&#39;input&#39;);<br>    inpt.type=&quot;text&quot;;<br>    <a href="http://inpt.name">inpt.name</a>=&quot;input_&quot; + c;<br>
    <a href="http://inpt.id">inpt.id</a>=&quot;txt_&quot; + c;<br>    inpt.setAttribute (&#39;autocomplete&#39;, &#39;off&#39;);<br>    inpt.setAttribute ( &#39;style&#39;, &quot;border:#000000 1px solid; width:250px;&quot;);<br>
    div.appendChild(inpt);<br>    //Link +<br>    div.innerHTML += &quot;&lt;a style=&#39;text-decoration:none&#39; href=&#39;#&#39; onclick=&#39;javascript:newInput()&#39;&gt; [+] &lt;/a&gt;&quot;;<br>    //Link -<br>    div.innerHTML += &quot;&lt;a style=&#39;text-decoration:none&#39; href=&#39;#&#39; onclick=&#39;javascript:removeInput(\&quot;div_&quot; + c + &quot;\&quot;)&#39;&gt; [-] &lt;/a&gt;&lt;br&gt;&quot;;<br>
    //Create DIV SUGGEST<br>    var divS = document.createElement(&#39;div&#39;);<br>    divS.id = &quot;suggest_&quot; + c;<br>    divS.setAttribute ( &#39;style&#39;, &quot;visibility:hidden; border:#000000 1px solid; width:auto;&quot;);<br>
    divS.setAttribute ( &#39;class&#39;, &quot;suggest&quot;);<br>    div.appendChild(divS);<br>    createAutoComplete1(<a href="http://inpt.id">inpt.id</a>, divS.id);<br>    c += 1;<br><br>}<br>function removeInput(id)<br>
{<br>    if(cantElementForm() &gt; 1)<br>        document.f1.removeChild(document.getElementById(id));<br>    else<br>        alert (&quot;ATENCIÓN!\nNo se puede borrar el único elemento de carga&quot;);<br>}<br><br>function cantElementForm()<br>
{<br>    return document.forms.item(0).elements.length;<br>}<br>/*]]&gt;*/<br>&lt;/script&gt;<br>&lt;style type=&quot;text/css&quot; media=&quot;all&quot;&gt;<br>.suggest{<br>    position:absolute;<br>    background:#fff;<br>
    width:200px;<br>    }<br><br>.suggest div{<br>    background:#fff;<br>    color:#000;<br>    padding-left:4px;<br>    cursor:hand;<br>    text-align:left;<br>    }<br><br>.suggest div.over{<br>    color:#fff;<br>    background:#000;<br>
    }<br>&lt;/style&gt;<br><br>&lt;script type=&quot;text/javascript&quot;&gt;<br><br>&lt;/script&gt;<br><br>&lt;/head&gt;<br><br>&lt;body onLoad=&quot;newInput(); createAutoComplete();&quot;&gt;<br>&lt;?php<br>    //echo &quot;Factura Nro.: &quot;.$_GET[&#39;FacturaID&#39;];<br>
    echo &quot;Factura Nro.: &quot;;<br>?&gt;<br>&lt;br /&gt;<br>&lt;div&gt;<br>    &lt;form action=&quot;#&quot; method=&quot;get&quot; name=&quot;f1&quot; id=&quot;f1&quot; autocomplete=off&gt;<br>&lt;!--        &lt;div id=&quot;div_0&quot;&gt;<br>
            &lt;input type=&quot;text&quot; name=&quot;searchField&quot; id=&quot;txt_0&quot; style=&quot;border:#000000 1px solid;width:150px;&quot; autocomplete=off&gt;<br>            &lt;a href=&quot;#&quot; onclick=&quot;javascript:newInput()&quot; style=&quot;text-decoration:none&quot;&gt; [+] &lt;/a&gt;&lt;br&gt;<br>
            &lt;div class=&quot;suggest&quot; id=&quot;suggest_0&quot; style=&quot;visibility:hidden;border:#000000 1px solid;width:150px;&quot;&gt;&lt;/div&gt;<br>           &lt;/div&gt;<br>--&gt;    &lt;/form&gt;<br>&lt;/div&gt;<br>
<br><br>&lt;/body&gt;<br>&lt;/html&gt;<br>