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 7074383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:03:00+00:00 2026-05-28T06:03:00+00:00

JSfiddle (showing the non-working code) here: http://jsfiddle.net/ts2Rr/ I have three boxes that a user

  • 0

JSfiddle (showing the non-working code) here: http://jsfiddle.net/ts2Rr/

I have three boxes that a user must click one at a time to see the content of that box. Upon seeing the content of that box the user inputs text into a textbox and then the next box is shown. However, the user only has five seconds to do so. Testing the code so far seems to indicate that the failure occurs around the if else statement but I can’t figure out what’s wrong. Without the if else statement in the code, everything works up to that point. With the if else statement in the code nothing works (not even the code before it).

With the if else statement I am trying to use two variables (one set upon the start of the function, and the other set when the user inputs text). I then subtract the two to get a millisecond time variable. If that is less than 5,000 ms record it to the hidden form field. Else, run a setTimeOut function that records 5 seconds to the hidden form field. Is this even possible?

//start after 3 seconds on page load
   //settimeout()
         //appends onclick onto #Box 1 that calls function Rate when clicked
         //.toggleclass onto  #Box1
         //300;

window.onload = function(){
     setTimeout(function(){
        $('#BoxE1').bind('click', function() {
                Rate();
                //alert('User clicked on "foo."');                    //uncomment for testing purposes only
            });
        $('#BoxE1').toggleClass('inactive active');
     }, 3000);
};

function Rate() {
    $('#E1Rate').show();                            //Show the object to be rated
    $('#BoxE1').unbind('click');                    //Prevent the user from clicking on the box again
    $('#BoxE1').toggleClass('inactive active');        //Toggles the box back to green
//Code works up to this point so far, if I need to rollback just add }; to the next line
    var startTime = new Date();
    var elaspedTime = (inputTime - startTime);         //Calculate the elasped milliseconds
    if (elaspedTime < 5000) {
        document.getElementById("E1RatingTime").value=elaspedTime;
    }
    else {
        setTimeout (function(){
            document.getElementById("E1RatingTime").value="5";
        }, 5000);
    }
    $('#E1Rate').hide();    
};
  • 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-05-28T06:03:01+00:00Added an answer on May 28, 2026 at 6:03 am

    Your code stops working because of a syntax error in

    SetTimeout function(){
    

    Correct it to

    setTimeout(function() {...}, 5000);
    

    Btw. getElementById() does not need the # hash before the id string. It even won’t work with the #

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

Sidebar

Related Questions

I have updated the code I am working on here http://jsfiddle.net/dFfJm/ At the first
http://jsfiddle.net/umbriel/CvhkM/1080/ In this fiddle I have managed to code so that when I hover
Here's the fiddle showing my problem: http://jsfiddle.net/7QaXL/1/ In the webkit-based browsers the padding of
I have created fiddle here: http://jsfiddle.net/ozzy/WEGMh/ How it should look is here: Issue is
It seems that a:visited won't work in showing background color on my links. http://jsfiddle.net/davestein/D2srA/
I have created a quick jsfiddle here showing it not working. The problem I
Why both border not showing? http://jsfiddle.net/r8mA7/ <table> <thead style=border-top:10px solid red; background:yellow> <tr><th style=border-top:10px
HTML viewable at jsfiddle.net (it's a lot of code to post here) The method
Please see this jsFiddle: https://jsfiddle.net/Wmq6f/ I have a textarea that has a background image,
UPDATE 2 - RESOLVED: Got it working: http://jsfiddle.net/7CvZ9/12/ Had to add some classes. UPDATE

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.