Ik ben een Online kraslot aan het maken en als ik alle vakjes heb open gekrast zou er een pop up moeten komen met een melding er in maar die komt niet.

	
<html>
<head>
	<script language="JavaScript1.2" type="text/javascript">

		function disableselect(e)
		{
			return false 		/*disabeling selection action*/
		}
		function reEnable()
		{
			return true
		}
		document.onselectstart=new Function ("return false")
		if (window.sidebar)
		{

			document.onclick=reEnable
		}	
		function clickIE()
		{
			if (document.all)
			{
				(message);
				return false;
			}
		}
		document.oncontextmenu=new Function("return false")		
	</script>
	<meta CHARSET="UTF-8">
	
	<title>Scratch Scratch</title>

	<!-- jQuery -->
	<script type="text/javascript" src="./inc/jquery.1.7.1.min.js"></script>

	<!-- wScratchPad -->
	<script type="text/javascript" src="./wScratchPad.js"></script>
	<link rel="stylesheet" href="css/main.css">
</head>
<body>
	<div id="positie">
		<div id="nummer1">
		</div>
		<div id="nummer2">
		</div>
		<div id="nummer3">
		</div>
		<div id="nummer4">
		</div>
		<div id="nummer5">
		</div>
		<div id="nummer6">
		</div>
		<div id="nummer7">
		</div>
		<div id="nummer8">
		</div>
		<div id="nummer9">
		</div>
	</div>
	<div id="logo">
			<img src="images/logo.jpg" style="WIDTH:350; HEIGHT:200px; border: solid 3px;"/> <!--moet nog een echt logo in-->
	</div>
	<script type="text/javascript">

			var cleared = 0;

			//scratchpad1
			var images = [], 
			index = 0;

			images[0] = "images/slide1.jpg";		//de plaatjes die je kunt vrij krassen
			images[1] = "images/slide2.jpg";
			images[2] = "images/slide3.jpg";
			images[3] = "images/logo.jpg";
			images[4] = "images/winner.png";
			images[5] = "images/scratch-to-win.png";

			index = Math.floor(Math.random() * images.length);

			$('#nummer1').wScratchPad({
			  scratchMove: function (e, percent) {
				console.log(percent);
				if (percent > 70)
				{
					this.clear();
					cleared = cleared + 1;
				}
			  }
			});
			$("#nummer1").wScratchPad('bg', images[index]);
			$("#nummer1").wScratchPad('fg', 'images/overlay.png');		//de laag die je weg krast
			$("#nummer1").wScratchPad('size', '15');				//grote van het vlak dat je ineens weg krast
			$("#nummer1").wScratchPad('cursor', 'url("./images/coin.png") 5 5, default');  //de muis die je hebt boven het krasveld
		    
		
			//scratchpad2
			var images = [], 
			index = 0;

			images[0] = "images/slide1.jpg";
			images[1] = "images/slide2.jpg";
			images[2] = "images/slide3.jpg";
			images[3] = "images/logo.jpg";
			images[4] = "images/winner.png";
			images[5] = "images/scratch-to-win.png";

			index = Math.floor(Math.random() * images.length);

			$('#nummer2').wScratchPad({
			  scratchMove: function (e, percent) {
				console.log(percent);
				if (percent > 70)
				{
					this.clear();
					cleared = cleared + 1;
				}
			  }
			});
			$("#nummer2").wScratchPad('bg', images[index]);
			$("#nummer2").wScratchPad('fg', 'images/overlay.png');
			$("#nummer2").wScratchPad('size', '15');
			$("#nummer2").wScratchPad('cursor', 'url("./images/coin.png") 5 5, default');
			
			//scratchpad3
			var images = [], 
			index = 0;

			images[0] = "images/slide1.jpg";
			images[1] = "images/slide2.jpg";
			images[2] = "images/slide3.jpg";
			images[3] = "images/logo.jpg";
			images[4] = "images/winner.png";
			images[5] = "images/scratch-to-win.png";

			index = Math.floor(Math.random() * images.length);

			$('#nummer3').wScratchPad({
			  scratchMove: function (e, percent) {
				console.log(percent);
				if (percent > 70)
				{
					this.clear();
					cleared = cleared + 1;
				}
			  }
			});
			$("#nummer3").wScratchPad('bg', images[index]);
			$("#nummer3").wScratchPad('fg', 'images/overlay.png');
			$("#nummer3").wScratchPad('size', '15');
			$("#nummer3").wScratchPad('cursor', 'url("./images/coin.png") 5 5, default');
			
			//scratchpad4
			var images = [], 
			index = 0;

			images[0] = "images/slide1.jpg";
			images[1] = "images/slide2.jpg";
			images[2] = "images/slide3.jpg";
			images[3] = "images/logo.jpg";
			images[4] = "images/winner.png";
			images[5] = "images/scratch-to-win.png";

			index = Math.floor(Math.random() * images.length);

			$('#nummer4').wScratchPad({
			  scratchMove: function (e, percent) {
				console.log(percent);
				if (percent > 70)
				{
					this.clear();
					cleared = cleared + 1;
				}
			  }
			});
			$("#nummer4").wScratchPad('bg', images[index]);
			$("#nummer4").wScratchPad('fg', 'images/overlay.png');
			$("#nummer4").wScratchPad('size', '15');
			$("#nummer4").wScratchPad('cursor', 'url("./images/coin.png") 5 5, default');
			
			//scratchpad5
			var images = [], 
			index = 0;

			images[0] = "images/slide1.jpg";
			images[1] = "images/slide2.jpg";
			images[2] = "images/slide3.jpg";
			images[3] = "images/logo.jpg";
			images[4] = "images/winner.png";
			images[5] = "images/scratch-to-win.png";

			index = Math.floor(Math.random() * images.length);

			$('#nummer5').wScratchPad({
			  scratchMove: function (e, percent) {
				console.log(percent);
				if (percent > 70)
				{
					this.clear();
					cleared = cleared + 1;
				}
			  }
			});
			$("#nummer5").wScratchPad('bg', images[index]);
			$("#nummer5").wScratchPad('fg', 'images/overlay.png');
			$("#nummer5").wScratchPad('size', '15');
			$("#nummer5").wScratchPad('cursor', 'url("./images/coin.png") 5 5, default');
			
			//scratchpad6
			var images = [], 
			index = 0;

			images[0] = "images/slide1.jpg";
			images[1] = "images/slide2.jpg";
			images[2] = "images/slide3.jpg";
			images[3] = "images/logo.jpg";
			images[4] = "images/winner.png";
			images[5] = "images/scratch-to-win.png";

			index = Math.floor(Math.random() * images.length);

			$('#nummer6').wScratchPad({
			  scratchMove: function (e, percent) {
				console.log(percent);
				if (percent > 70)
				{
					this.clear();
					cleared = cleared + 1;
				}
			  }
			});
			$("#nummer6").wScratchPad('bg', images[index]);
			$("#nummer6").wScratchPad('fg', 'images/overlay.png');
			$("#nummer6").wScratchPad('size', '15');
			$("#nummer6").wScratchPad('cursor', 'url("./images/coin.png") 5 5, default');
			
			//scratchpad7
			var images = [], 
			index = 0;

			images[0] = "images/slide1.jpg";
			images[1] = "images/slide2.jpg";
			images[2] = "images/slide3.jpg";
			images[3] = "images/logo.jpg";
			images[4] = "images/winner.png";
			images[5] = "images/scratch-to-win.png";

			index = Math.floor(Math.random() * images.length);

			$('#nummer7').wScratchPad({
			  scratchMove: function (e, percent) {
				console.log(percent);
				if (percent > 70)
				{
					this.clear();
					cleared = cleared + 1;
				}
			  }
			});
			$("#nummer7").wScratchPad('bg', images[index]);
			$("#nummer7").wScratchPad('fg', 'images/overlay.png');
			$("#nummer7").wScratchPad('size', '15');
			$("#nummer7").wScratchPad('cursor', 'url("./images/coin.png") 5 5, default');
			
			//scratchpad8
			var images = [], 
			index = 0;

			images[0] = "images/slide1.jpg";
			images[1] = "images/slide2.jpg";
			images[2] = "images/slide3.jpg";
			images[3] = "images/logo.jpg";
			images[4] = "images/winner.png";
			images[5] = "images/scratch-to-win.png";

			index = Math.floor(Math.random() * images.length);

			$('#nummer8').wScratchPad({
			  scratchMove: function (e, percent) {
				console.log(percent);
				if (percent > 70)
				{
					this.clear();
					cleared = cleared + 1;
				}
			  }
			});
			$("#nummer8").wScratchPad('bg', images[index]);
			$("#nummer8").wScratchPad('fg', 'images/overlay.png');
			$("#nummer8").wScratchPad('size', '15');
			$("#nummer8").wScratchPad('cursor', 'url("./images/coin.png") 5 5, default');
			
			//scratchpad9
			var images = [], 
			index = 0;

			images[0] = "images/slide1.jpg";
			images[1] = "images/slide2.jpg";
			images[2] = "images/slide3.jpg";
			images[3] = "images/logo.jpg";
			images[4] = "images/winner.png";
			images[5] = "images/scratch-to-win.png";

			index = Math.floor(Math.random() * images.length);

			$('#nummer9').wScratchPad({
			  scratchMove: function (e, percent) {
				console.log(percent);
				if (percent > 70)
				{
					this.clear();
					cleared = cleared + 1;
				}
			  }
			});
			$("#nummer9").wScratchPad('bg', images[index]);
			$("#nummer9").wScratchPad('fg', 'images/overlay.png');
			$("#nummer9").wScratchPad('size', '15');
			$("#nummer9").wScratchPad('cursor', 'url("./images/coin.png") 5 5, default');
			
			
			if (cleared === 9)
			{
				window.alert('alle vakjes zijn open gekrast');
				window.location.href="geenprijs.php";
			}
			
		
	</script>
	<script type="text/javascript">
		$("#nummer2").wScratchPad({});		
		$("#nummer3").wScratchPad({});
		
		$("#nummer4").wScratchPad({});		
		$("#nummer5").wScratchPad({});
		$("#nummer6").wScratchPad({});

		$("#nummer7").wScratchPad({});		
		$("#nummer8").wScratchPad({});
		$("#nummer9").wScratchPad({});			
	</script>
</body>
</html> 


ik heb 9 kras vakjes en elke keer als ik er een heb open gekrast moet er 1 bij mijn var boven in worden geteld.
uiteindelijk als ik ze heb open gekrast zou er een alert moeten komen volgens mijn if statement onder in de code.
er komt geen alert maar bij elk vakje wat voor 70 % word open gekrast word wel meteen leeg gemaakt.

als iemand mij zou kunnen helpen zou ik het heel erg op prijs stellen.

mvg,

Bram poulisse
Ik heb je code uitgeprobeerd maar de alert komt al als ik 1 vakje open kras.
en die moet pas komen als ze alle 9 zijn open gekrast.
Je hebt een alert, dit is vooruitgang :P. Zonder een werkend voorbeeld word het een beetje tricky om te debuggen
Ik heb het antwoord
 if (percent >= 70 && percent != 100)


dit moet in de if staan van dit stuk
$('#nummer' + counter).wScratchPad({
                  scratchMove: function (e, percent) {
                    console.log(percent);
                    if (percent >= 70 && percent != 100)
                    {
                        this.clear();
                        cleared = cleared + 1;
                        if (cleared === 9)
                        {
                            window.alert('alle vakjes zijn open gekrast');
                            window.location.href="geenprijs.php";
                        }
                    }
                  }
                });
                $("#nummer" + counter).wScratchPad('bg', images[index]);
                $("#nummer" + counter).wScratchPad('fg', 'images/overlay.png');
                $("#nummer" + counter).wScratchPad('size', '50');
                $("#nummer" + counter).wScratchPad('cursor', 'url("./images/coin.png") 5 5, default');
                counter = counter + 1;


zo werkt de code wel.
super bedankt voor al je hulp.
het word heel erg gewaardeerd.
Bram,
Mag ik de link? ben benieuwt hoe het werkt.

Reageren