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

141
Vistas
disable two buttons after clicking reject/close

My task is to be able to disable the approve and return buttons after clicking the reject button. Reject button means closing a project. These are my codes. Can anybody help me figure out how to disable the buttons?this is what the button looks like.

<div class="text-center ">
    <button class="btn m-1 align-items-center btn-success text-center " id="approve">Approve</button>   
    <button class="btn btn-danger m-1 align-items-center text-center " id="clear" onclick="sweetalertrejects()">Reject</button>
    <button class="btn btn-secondary m-1 align-items-center text-center" id="return">Return</button>       
    </div>
    </div>
    </div>
                        <script>
                        function sweetalertrejects(){
                            swal("This button means closing the task. You will not be able to revert this action. Do you wish to continue?", {
                                icon: "info",
                                  buttons: {
                                    cancel: "Cancel",
                                    catch: {
                                      text: "Yes, close this task",
                                      value: "cancel",
                                    },
                                    
                                  },
                                })
                                .then((value) => {
                                  switch (value) {
                                 
                                
                                    case "cancel":
                                      swal("Closed!", "Task has been closed.", "success");
                                      break;
                                 
                                    default:
                                      swal("Task has not been closed.");
                                  }
                                });

                        }
                        </script>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can get the buttons by id and disable them as follows:

document.getElementById("approve").disabled = true;
document.getElementById("return").disabled = true;

Here is whole code

function sweetalertrejects(){
swal("This button means closing the task. You will not be able to revert this action. Do you wish to continue?", {
  icon: "info",
  buttons: {
    cancel: "Cancel",
    catch: {
      text: "Yes, close this task",
      value: "cancel",
    },

  },
})
  .then((value) => {
  switch (value) {


    case "cancel":
      swal("Closed!", "Task has been closed.", "success").then(()=>{
      document.getElementById("approve").disabled = true;
      document.getElementById("return").disabled = true;

      });
      break;

    default:
      swal("Task has not been closed.");
  }
});
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to include classname "disable" to the Approve & Return button and your javascript code should look like this:

<script>
$('#clear').click(function() {

    swal("This button means closing the task. You will not be able to revert this action. Do you wish to continue?", {   
    icon: "info",
        buttons: {
        cancel: "Cancel",
        catch: {
            text: "Yes, close this task",
            value: "cancel",
        },
        
        },
    })
    .then((value) => {
        if(value){
            $('.disable').attr('disabled','disabled');
            swal("Closed!", "Task has been closed.", "success");
        }else{
            swal("Task has not been closed.");
        }
    });

});
</script>
about 4 years ago · Juan Pablo Isaza Denunciar
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