You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			JavaScript
		
	
| 
 | |
| $(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('<option value="">Select a Project</option>');
 | |
|                     $('#product-select').append('<option value="">Select a Product</option>');
 | |
| 
 | |
|                     response.projects.forEach(function (project) {
 | |
|                         $('#project-select').append('<option value="' + project.id + '">' + project.name + '</option>');
 | |
|                     });
 | |
| 
 | |
|                     response.products.forEach(function (product) {
 | |
|                         $('#product-select').append('<option value="' + product.id + '">' + product.name + '</option>');
 | |
|                     });
 | |
|                 },
 | |
|                 error: function (xhr, status, error) {
 | |
|                     console.error("Error fetching customer data:", error);
 | |
|                 }
 | |
|             });
 | |
|         } else {
 | |
|             $('#project-select').empty();
 | |
|             $('#product-select').empty();
 | |
| 
 | |
|             $('#project-select').append('<option value="">Select a Project</option>');
 | |
|             $('#product-select').append('<option value="">Select a Product</option>');
 | |
|         }
 | |
|     });
 | |
| });
 |