javascript - jQuery submit form IF -
hey guys, have great scripts on stack overflow helped me out with, except 1 major function need missing.
this game user picks number (by entering number in text field) hits play button. after hit play button series of numbers appear, have click on number matches number.
the query script i'm using counts how many times hit number , how many times missed number. take @ script in action here. link text
now need do, send score (hits , misses ) database after 3 misses, can keep high score. ideas? here's 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(); (var = 0; < 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; });
i updated fiddle solution. check http://jsfiddle.net/dhpqt/2/.
i marked new stuff comment in form of
//new ....
the main thing checking after
$('#misscount').text(++misscount);
if misscount
3 , if yes stop game , send something
Comments
Post a Comment