0

When I used zii.widgets.jui.CJuiAutoComplete' widget, I got 2 problems

P1) when I create an array as follow

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

it isn't working. But if the array like this

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

It is working fine.

Q1 ) How should I do to work the widget with the array as follow?

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

p2) When I select a value by above widget, I want to get some data from DB and put them into other input boxes by ajax.

Q2) How should I do?

Ninad
  • 1,871
  • 3
  • 15
  • 23
Thu Ra
  • 2,013
  • 12
  • 48
  • 76

1 Answers1

0

Fo P1 of your question pass the data in json format and try

For p2 of your question u may use ajax as shown

$('#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"); 
                }
        });
})

Or else you may refer this thread to achieve your task for update into textbox AutoComplete update demo

Ninad
  • 1,871
  • 3
  • 15
  • 23