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

The Archive Base Latest Questions

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

This is a game were a user enters a random number, then clicks Play,

  • 0

This is a game were a user enters a random number, then clicks “Play”, they’ll see a set of boxes appear with randomly generated numbers. The object of the game is to click on the box that has your number to build points.

How can I make it so, they lose points if they don’t click on the box that has their number.

see game here: link text

solutions I’ve tried.

 if ($('#randomnumber li').hasClass('')) {
    if (parseInt($this.text(), 10) === n) {
        $this.addClass('wrong');
        $('#hitcount').text(--hitCount);
    } 
}

thought the .attr(‘class’, ”) gave all li’s a ” class

  if ($('<li />').hasClass('')) {
    if (parseInt($this.text(), 10) === n) {
        $this.addClass('wrong');
        $('#hitcount').text(--hitCount);
    } 
}

Tried several other variations of the above code including

if($('#randomnumbers li')not.('Clicked')

nothing worked

here’s the complete script

var hitCount = 0,
missCount = 0;

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

         $("#getit").click(function() {
//Resets Game to 0 points

var hitCount = 0,
missCount = 0;
$('#misscount').text(0);
$('#hitcount').text(0);
$('#message').hide(100);        
$('#randomnumber').empty();
$('#randomnumber').show(300);

//starts game get users value

var li = [],
    intervals = 0,
    n = parseInt($('#MyNumber').val());

//set game speed

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

 //empty all numbers in the boxes 

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

 //generate new boxes 

for (var i = 0; i < 7; i++) {
    li.push($('<li />').one('click', function() {
        BoxClick.call(this, n);
    }).appendTo('#randomnumber'));
}

//get which box is clicked 

function BoxClick(n) {
var $this = $(this);
$('#randomnumber li').unbind().one('click', function() {
        BoxClick.call(this,n);
});
$this.unbind();

//add points if the box clicked matches the users value, subtract points if they don't.

    if (!$this.hasClass('clicked')) {
    if (parseInt($this.text(), 10) === n) {
        $this.addClass('correct');
        $('#hitcount').text(++hitCount);
    } else {
        $this.addClass('wrong');
        $('#misscount').text(++missCount);
    }
 }
     //if user gets three misses submit score to database

            if(missCount==<?php echo $limit ?>){
               clearInterval(intervalId);
               $('#randomnumber').hide(300);

                $.ajax({
type : 'POST',
url : 'FBhighscore_hwnd.php',
dataType : 'json',
data: {
tgameid: $('#tgameid').val(),MyNumber: $('#MyNumber').val(),totalHits: hitCount
},
success : function(data){
$('#waiting').hide(500);
$('#message').removeClass().addClass((data.error === true) ? 'error' : 'success')
.text(data.msg).show(500);
if (data.error === true)
$('#loginForm').show(500);
else
$('#send').hide(500);       
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
$('#waiting').hide(500);
$('#message').removeClass().addClass('error')
.text('There was an error.').show(500);
$('#loginForm').show(500);
}
});

            }


$this.addClass('clicked');
}
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:08:59+00:00Added an answer on May 18, 2026 at 3:08 am

    Since you are already tagging a box with the “correct” class when the user clicks the correct answer, couldn’t you just check for the lack of that class when you change a box’s number? Something along the lines of this:

    function ChangeBoxNumber(box) {
       if (parseInt(box.text(), 10) === n && !box.hasClass('correct')) {
           //missed answer, you lose a point!
       }
       //change number
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a simple Guess-The-Number game I'm making, the user inputs a couple of numbers
I'm looking to create a simple jquery game. It starts like this, the user
This is my setup. The user can connect with facebook. I then use the
I guess I'll illustrate with an example: In this game you are able to
I am developing a game for the web. The map of this game will
I've been playing this flash game and after I'd gotten over the initial ('lol,
I have code like this to move the player in my game left, right,
I'm designing a game server and I have never done anything like this before.
I'm trying to solve this flickering problem on the iphone (open gl es game).
I'm thinking about making a networked game. I'm a little new to this, and

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.