Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

288
Views
How to disable a button on click on another page?

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!