﻿$(function() {
$( "#ctl00_ddlLocation" ).autocomplete({
	source: function(request, response) {
    $.ajax({
        url: "getLocation.ashx?location=" + document.getElementById("ctl00_ddlLocation").value,
        contentType: "application/json; charset=utf-8",
        dataFilter: function(data) { return data; },
        success: function(data) {
            response($.map(data.d, function(item) {
                return {
                    value: item.Branch
                }
            }))
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
        }
    });
    },
    minLength: 1            
});

$( "#ctl00_DropDownList1" ).autocomplete({
	source: function(request, response) {
    $.ajax({
        url: "getLocation1.ashx?location=" + document.getElementById("ctl00_DropDownList1").value + "&branch=" + document.getElementById("ctl00_ddlLocation").value,
        contentType: "application/json; charset=utf-8",
        dataFilter: function(data) { return data; },
        success: function(data) {
            response($.map(data.d, function(item) {
                return {
                    value: item.Branch
                }
            }))
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
        }
    });
    },
    minLength: 1            
});

$( "#ctl00_DropDownList2" ).autocomplete({
	source: function(request, response) {
    $.ajax({
        url: "getLocation2.ashx?location=" + document.getElementById("ctl00_DropDownList2").value + "&branch=" + document.getElementById("ctl00_ddlLocation").value + "&sub=" + document.getElementById("ctl00_DropDownList1").value,
        contentType: "application/json; charset=utf-8",
        dataFilter: function(data) { return data; },
        success: function(data) {
            response($.map(data.d, function(item) {
                return {
                    value: item.Branch
                }
            }))
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
        }
    });
    },
    minLength: 1            
});
});
