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

196
Vistas
How to check diffTime > Date.now to enable and disable an element
Goals: 
-Get stored time button was last clicked
-If stored time is greater than (>) Date.now() - delay then enable the button

I need to have this button operate as follows, mind you this is javascript done in Velo (Wix)

User click > grab current time of click to a database (done) check the time of the database against date.now and get a differential of time (done)

Now I need to write an if-else for enabling and disabling the button until a delayed disable is done.

Here is what I have written so far:

$w.onReady(function () {
  $w.onReady( () => {
  $w("#dataset2").onReady( () => {
    const itemObj = $w("#dataset2").getCurrentItem();
    const dateNow = new Date();
    const updatedDate = itemObj._updatedDate;
    const diffTime = Math.abs(updatedDate - dateNow);
    const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
    console.log(diffTime + "milliseconds");
  });
});
  console.log("Site is ready & button enabled.");
}); 

export function button1_click_1(event) {
  $w('#button1').label = "Currently Occupied"

  if (diffTime > Date.now) {
  setTimeout(function() {
        $w("#button2").enable();
  }, 20000);
} else if (Date.now < diffTime) {
  $w('#button1').disable();
} else {
  $w('#button1').enable();
  console.log('Button Clicked and checked.');
}}
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