Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda