I have a web page (using thymeleaf, html, css, javascript) and there is a search bar with a button. I want another button disabled whenever the first one is clicked. I tried to do it with a javascript code like this :
const button1 = document.querySelector('#button1');
const button2 = document.querySelector('#button2');
const disableButton = () => {
button1.disabled = true;
};
button2.addEventListener('click', disableButton);
But the problem is that when I click the search button it actually redirects me to another page and that code is only working on one page. I also tried to use thymeleaf if expression like this:
<div th:if="${#httpServletRequest.requestURI == '/example/WEB-INF/views/inbox.jsp'}">
some content
</div>
But it throws an excpetion as httpServletRequest is null/or not recognized. So I have two buttons with ids and I want to disable one of them when the other is clicked and redirects me to antoher page. How do I achieve that?