Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8136817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:52:41+00:00 2026-06-06T10:52:41+00:00

I am having a terrible time figuring this one out. I have a form.

  • 0

I am having a terrible time figuring this one out. I have a form.

<form id="form1" .. target="right" action="blablah">
<input .. />
<input type="submit" id="ycsubmit" onclick="..." value="Go!" />
</FORM>

I have a function I need executed on submit: ycClick();

Once ycClick() is executed I need to toggle onClick to null for 30 seconds, then toggle back so that if pressed again after 30s it will execute ycClick() a second time,then disable it for another 30s, and so forth. I’ve tried this 100 different ways but this is what I’ve got now:

function ycClick(){
...
}

var isEnabled = true;

function toggleSubmit() {
    if (isEnabled = true) {
        document.getElementById("ycsubmit").onclick = null;
    } else {
        document.getElementById("ycsubmit").onclick = timer();
    } 
//isEnabled = !isEnabled;
}

function timer(){
ycClick();
toggleSubmit();
setTimeout("toggleSubmit()", 30000);
}

Then I’ve got onclick set to trigger timer();
As is, this sets off timer(), which sets off ycClick() and then toggles onclick to null, but does not toggle it back after 30 seconds. I suspect it has something to do with this line:

isEnabled = !isEnabled;

but removing made no difference, it still operates exactly the same.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:52:46+00:00Added an answer on June 6, 2026 at 10:52 am

    You could do this:

    function ycClick () {
        var timestamp = +( new Date );
        if ( ycClick.timestamp && timestamp - ycClick.timestamp < 30000 ) return;
        ycClick.timestamp = timestamp;
    
        // the actual code of the function
    }
    

    Live demo: http://jsfiddle.net/znKRC/7/

    In my demo, click on the button repeatedly, and you’ll notice that the second part of the function is only executed every 3 seconds. So, the first three lines of the function above make sure that the subsequent code is only executed if it has not been executed in the last 30 seconds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a terrible time trying to get an input box like the
I'm experiencing the strangest problem and have been having a terrible time debugging it.
I have been having a terrible time trying to compile a python extension -
I am having a hard time figuring out how to write to and read
I'm new to Silverlight 4 and having a tough time googling this one since
I'm having a terrible time trying to hook up functions at runtime (which I
My title is terrible but I'm having a hard time wrapping my head around
I'm having a terrible time convincing myself what I've done here is a good
I am having a terrible time getting my height of my DIVs to properly
I'm having a terrible time with a MySQL query. I've spent most of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.