1

I want to show the value in autocomplete.

Refer my code below:

<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" ></script>
<script>
    <?php 
    $zipdata = array();
    $zipval =array();
        foreach ($storeCollection as $key => $value){ 

            if ($value['latitude']==0 || $value['longitude']==0){
                continue; 
            } 

            $zipdata[]  = $value['name'].' '.$value['city'].' '.$value['state_province'].' '.$value['postal_code'];
            $zipval[] =  $value['name'].', '.$value['city'].', '.$value['state_province'];

        } 

        if(count($zipdata) > 0){ ?>
            jQuery(document).ready(function(){

                var zipdata = <?php echo json_encode($zipdata); ?> ;
                var zipval = <?php echo json_encode($zipval); ?> ;

                console.log('zipdata',zipdata);
                console.log('zipval',zipval);

        jQuery( "#retailer" ).autocomplete({
        source: zipdata
    });
            });

        <?php } ?>  



   /* $("#retailer").keyup(function(){
        $.ajax({
        type: "POST",
        url: "Grid.php"
        data:'keyword='+$(this).val(),
        beforeSend: function(){
            $("#retailer");
        },
        success: function(data){
            $("#suggesstion-box").show();
            $("#suggesstion-box").html(data);
            $("#retailer").css("background","#FFF");
        }
        });
    });*/
/*function selectCountry(val) {
    $("#retailer").val(val);
    $("#suggesstion-box").hide();
}*/
</script>

But I am not able to achieve it.

Any help would be appreciated

  • what's the problem with it? What is $modelCollection? Where does it come from? – Marius Apr 1 at 7:14
  • The problem is I am not able to autocomplete this input field.. – Amy Apr 1 at 7:15
  • $modelcollection is my custom module, where I am getting the collection to show in this input field. – Amy Apr 1 at 7:17
  • The values are coming through this field, but I am not able to autocomplete it. – Amy Apr 1 at 7:18
  • 1
    maybe you should add that to the question. Maybe show a screenshot with what's happening. – Marius Apr 1 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.