$(document).ready(function(){
    
    $('body').on("click", ".search", getCustomer);

    function getCustomer(){
        var custname    = $(".custname").val(),
                data    = {custname : custname},
                values  = "";
        
        $.ajax({
            type    : 'GET',
            dataType: 'json',
            url     : "getCust.php",
            data    : data,
            success : function (response) {
                $.each(response, function () {
                    values += "<tr>" +
                            "<input type='hidden' class='form-control accode'  name='accode_" + this.ctr + "' value='"+ this.accode+"'>" +
                            "<td align='right'><input type='text' class='form-control name'  name='name_" + this.ctr + "' value='"+ this.name+"'></td>" +
                            "<td align='right'><input type='text' class='form-control city'  name='city_" + this.ctr + "' value='"+ this.city+"'></td>" +
                            "<td align='right'><input type='text' class='form-control station'  name='station_" + this.ctr + "' value='"+ this.station+"'></td>" +
                            "<td align='right'><input type='text' class='form-control pin'  name='pin_" + this.ctr + "' value='"+ this.pin+"'></td>" +
                            "<td align='right'><input type='text' class='form-control tel'  name='tel_" + this.ctr + "' value='"+ this.tel+"'></td>" +
                            "<td align='right'><input type='text' class='form-control mobile'  name='mobile_" + this.ctr + "' value='"+ this.mobile+"'></td>" +
                            "</tr>";
                    $("#items").val(this.ctr);
                });
                $(".tbody").empty();
                $(".tbody").html(values);
            }
        });
    }
    
    getCustomer();
    
    
});