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

  • Home
  • SEARCH
  • 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 3391868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:51:11+00:00 2026-05-18T03:51:11+00:00

Hey guys, I have this great scripts someone on stack overflow helped me out

  • 0

Hey guys,
I have this great scripts someone on stack overflow helped me out with, except the one major function I need is missing.

This is a game where the user picks a number (by entering that number in a text field) then hits a play button. After they hit the play button a series of numbers will appear, they then have to click on the number that matches their number.

The query script I’m using counts how many times they hit the number and how many times they missed the number. Take a look at the script in action here. link text

now what I need it to do, is send the score (hits and misses ) to a database after 3 misses, so I can keep high score. Any ideas? Here’s the script.

var hitCount = 0,
missCount = 0;

function IsNumeric(n) {
return !isNaN(n);
}

$("#getit").click(function() {
var li = [],
    intervals = 0,
    n = parseInt($('#MyNumber').val());

if (IsNumeric(n)) {
    setInterval(function() {
        li[intervals++ % li.length].text(Math.random() > .1 ? Math.floor(Math.random()        * (10 + n) + (n / 2)) : n).attr('class', '');
    }, <?php echo $time ?>);
}

$('#randomnumber').empty();

for (var i = 0; i < 5; i++) {
    li.push($('<li />').click(function() {
        var $this = $(this);

        if (!$this.hasClass('clicked')) {
            if (parseInt($this.text(), 10) === n) {
                $this.addClass('correct');
                $('#hitcount').text(++hitCount);
            } else {
                $this.addClass('wrong');
                $('#misscount').text(++missCount);
            }
        }

        $this.addClass('clicked');
    }).appendTo('#randomnumber'));
}

return false;
});
  • 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-18T03:51:12+00:00Added an answer on May 18, 2026 at 3:51 am

    I updated your fiddle with the solution. Check http://jsfiddle.net/DHPQT/2/.

    I marked all the new stuff with a comment in the form of

    //new ....
    

    The main thing to do is checking after

    $('#misscount').text(++missCount);
    

    if missCount is 3 and if yes stop the game and send something

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

Sidebar

Related Questions

Hey guys! I have this little problem: I have one ViewController which adds 2
Hey guys, I have this quick bit of code that I can't figure out
Hey guys I need some help with this: I have two view controllers, let's
Hey guys, have a little issue i need to figure out. I created a
Hey guys, I want to make a function loop over all elements that have
Hey guys, I have developed a small site that i would like to embed
Hey guys, this is my first time actually posting at stackflow but i've used
Hey guys! I feel like I have gotten a good grasp on IE6 and
Hey guys I have a simple create method with some validations and whenever the
Hey guys, I have a client who wants their front site to have a

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.