From 5805ef54a7ff25f4f3e7456cd202f81e7bbc939e Mon Sep 17 00:00:00 2001 From: Thunder Date: Wed, 6 Mar 2024 09:30:57 +0700 Subject: [PATCH] Fix error getting parameter in front-end --- .../view/jsp/management/order/add-order.jsp | 13 ++++ .../order/add-product-into-order.jsp | 59 ++++++++++++++----- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/src/main/webapp/view/jsp/management/order/add-order.jsp b/src/main/webapp/view/jsp/management/order/add-order.jsp index b69eba1..75e2be9 100644 --- a/src/main/webapp/view/jsp/management/order/add-order.jsp +++ b/src/main/webapp/view/jsp/management/order/add-order.jsp @@ -177,6 +177,19 @@ { label: "${customer.name}", value: "${customer.ID}" }, ]; + + customerNameInput.on('input', function () { + var inputText = $(this).val().trim().toLowerCase(); + var matchedCustomer = customers.find(function (customer) { + return customer.label.toLowerCase() === inputText; + }); + + if (matchedCustomer) { + customerIdInput.val(matchedCustomer.value); + } else { + customerIdInput.val(''); + } + }); customerNameInput.autocomplete({ source: function (request, response) { diff --git a/src/main/webapp/view/jsp/management/order/add-product-into-order.jsp b/src/main/webapp/view/jsp/management/order/add-product-into-order.jsp index 717bae0..0c29c51 100644 --- a/src/main/webapp/view/jsp/management/order/add-product-into-order.jsp +++ b/src/main/webapp/view/jsp/management/order/add-product-into-order.jsp @@ -22,7 +22,7 @@ - +
<%@include file="../../../common/_sidenav.jsp" %>
@@ -123,28 +123,59 @@ +