$(document).ready(function () {
$('#customer-select').change(function () {
var customerId = $(this).val();
if (customerId) {
var url = '/add/fetch-customer-information/' + customerId + '/';
$.ajax({
url: url,
method: "GET",
success: function (response) {
$('#project-select').empty();
$('#product-select').empty();
$('#project-select').append('');
$('#product-select').append('');
response.projects.forEach(function (project) {
$('#project-select').append('');
});
response.products.forEach(function (product) {
$('#product-select').append('');
});
},
error: function (xhr, status, error) {
console.error("Error fetching customer data:", error);
}
});
} else {
$('#project-select').empty();
$('#product-select').empty();
$('#project-select').append('');
$('#product-select').append('');
}
});
});