Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-27-2010, 06:29 PM   PM User | #1
mrnightowl
New Coder

 
Join Date: Jul 2007
Posts: 78
Thanks: 6
Thanked 2 Times in 2 Posts
mrnightowl is an unknown quantity at this point
Cool Click Track for JS Game

I've been playing around on my off time from other work to learn javascript better so I made this little php javascript game that randomly puts 10 boxes in different locations in a 10x10 table. The object is to close the boxes by clicking them and get timed on how long it takes to close all 10 boxes.

The problem is you can click the same box real fast and only have to click a couple boxes for the timer to stop. So what I'd like to know what is the best way to only accept one click for each box generated. Here is what I'm using so far for the click validation:

Code:
<script language="javascript">
var tovalidate = 10;
function validate()
{
tovalidate -= 1;
if(tovalidate === 9)
starttimer();
if(tovalidate === 0)
stoptimer();
}
</script>
And using Jquery to fade the boxes pretty after click and trigger the validator:

Code:
<script>
  $("#<?=$c;?>").click(function () {  /*where $c is id generated for each specific box */
  $("#<?=$c;?>").fadeOut("slow");
  validate();
  });
  </script>
__________________
Notepad the only way to learn.
mrnightowl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:36 AM.


Advertisement
Log in to turn off these ads.