Ramco Ramco

Ramco Ramco

  • 443
  • 3.4k
  • 527.4k

Declaration or Statement expected

Jun 13 2023 4:58 AM

Hi

   In below code on last } i am getting above error

<script>
        var ddl = document.getElementById("ddlBook");
        alert(ddl);

        // Attach an event listener to the dropdown's change event
        ddl.addEventListener("change", function () {
            var selectedValue = ddl.value;

            // Get all the table cells with the 'sessionDeliveryNo' class
            var cells = document.getElementsByClassName("sessionDeliveryNo");

            for (var i = 0; i < cells.length; i++) {
                cells[i].classList.remove("highlight");
            }

            // Loop through the cells and check if their text matches the selected value
            for (var i = 0; i < cells.length; i++) {
                if (cells[i].textContent === selectedValue) {
                    // Add the 'highlight' class to the matching cell
                    cells[i].classList.add("highlight");
                }
            }
            });
        }
    </script>

Thanks


Answers (1)