Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

287
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda