0

当我使用 zii.widgets.jui.CJuiAutoComplete' 小部件时,我遇到了 2 个问题

P1)当我创建一个数组如下

a[1]=>'aa'
a[2]=>'bb'
a[3]=>'cc'

它不工作。但是如果数组像这样

a[0]=>'aa'
a[1]=>'bb'
a[2]=>'cc'

它工作正常。

Q1)我应该如何使用数组来处理小部件,如下所示?

a[1]=>'aa'
a[2]=>'bb'
a[3]=>'cc'

p2)当我通过上面的小部件选择一个值时,我想从 DB 中获取一些数据并通过 ajax 将它们放入其他输入框中。

Q2) 我该怎么办?

4

1 回答 1

0

您问题的 Fo P1 以 json 格式传递数据并尝试

对于您的问题的 p2,您可以使用 ajax,如图所示

$('#yourautoCompleteId').change(function(){
    var selecteddata=$(this).val();
    $.ajax({
        url: "'.$this->createUrl('Controller/yourMethod').'",
        data: {
            //special:specialisation,
            data   :selecteddata,
            },
            type:"GET",//you can also use POST method
            dataType:"html",//you can also specify for the result for json or xml
            success:function(response){
                //write the logic to get the response data as u need and set it to the fields 
                $("#dataId").val("SetHere");
                $('#quantityId').val("setHere");
             },
             error:function(){
                    //TODO: Display in the poll tr ifself on error   
                    alert("Failed request data from ajax page"); 
                }
        });
})

或者你可以参考这个线程来完成你的更新到文本框自动完成更新演示的任务

于 2013-07-02T09:03:33.090 回答