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

197
Views
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
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!