Antworten auf deine Fragen:
Neues Thema erstellen

Antworten zum Thema „javascriptproblem“

lomion

Aktives Mitglied

Hi an alle,
habe folgendes problem...ich möchte gerne ein kleines javascriptspiel auf ne HP packen...hab ich in einem Heft gefunden...soweit funktioniert das auch alles...nur möchte ich gerne anstatt der farbigen kästchen, bilder(ca. 20x20px) in den kästchen haben...ich hoffe da kann mir wer helfen...
VIELEN DANK schon mal im voraus :)

hier der

und hier der quelltext:
Code:
<script language="javascript">

var index;
var objBox;
var box;
var iTimesAnimate;
var blnGameStarted;
var TotalDisplay;

index=10;
blnGameStarted = false;

TotalDisplay = 0;

function changeColorOn(abc)
{
	abc.color="white";
	abc.backgroundColor="black"
}
function changeColorOff(abc)
{
	abc.color="black";
	abc.backgroundColor="white"
}
function animate()
{
	document.herwick.btnStart.disabled = true;
	if(index < 102)
	{
		document.all[index-1].style.backgroundColor="white";
		document.all[index].style.backgroundColor="red";

		setTimeout('animate()',75);
		index = index + 1;
	}
	else
	{
		setTimeout('document.all[101].style.backgroundColor="white"',75);
		initialize();
	}
}

function checkClick(objBox1)
{
	if(blnGameStarted)
	{
		objBox = objBox1;
		if(objBox.backgroundColor == "red")
		{
			document.herwick.txtScore.value = eval(document.herwick.txtScore.value) + 1;
		}
		else
		{
			objBox.backgroundColor = "blue";
			setTimeout('objBox.backgroundColor = "white"',200);
		}
	}
}

function getRandom()
{
	return (Math.round(Math.random()*(97-9)))+9;
}

function highlightBox()
{
	if(blnGameStarted)
	{
		box = getRandom();
		document.all[box].style.backgroundColor = "red";
		TotalDisplay = TotalDisplay + 1;

		setTimeout('document.all[box].style.backgroundColor = "white"',700);
		setTimeout('highlightBox()',800);
	}
}

function startTime()
{
	if(eval(document.herwick.txtTime.value)  != 0)
	{
		document.herwick.txtTime.value = eval(document.herwick.txtTime.value) - 1;
		setTimeout('startTime()',1000);
	}
	else
	{
		alert('Zeit vorbei!!! \n\n Bitte tragen Sie sich in der Highscore ein!');
		document.herwick.btnStart.disabled = false;
		blnGameStarted = false;
	}
}

function initialize()
{
	blnGameStarted = confirm('Sind Sie bereit Ihre Reflexe zu testen??')
	if(blnGameStarted)
	{
		document.herwick.txtTime.value = 30;
		document.herwick.txtScore.value = 0;
		setTimeout('startTime()',10);
		highlightBox();
	}
	else
		document.herwick.btnStart.disabled = false;
}
</script>
<html>
<head>

<title>Herwick - Reflextester</title>
</head>
<body onLoad="javascript:animate();" style="cursor:default">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td align="center" valign="middle">
			<table width="400" border="4" cellpadding="8" cellspacing="0" style="border-color:blue;boder-style:outset">
				<tr>

					<input type='hidden' name="9"></font>
					<td name="10" onClick="javascript:checkClick(this.style);">&</td>
					<td name="11" onClick="javascript:checkClick(this.style);">&</td>
					<td name="12" onClick="javascript:checkClick(this.style);">&</td>
					<td name="13" onClick="javascript:checkClick(this.style);">&</td>
					<td name="14" onClick="javascript:checkClick(this.style);">&</td>
					<td name="15" onClick="javascript:checkClick(this.style);">&</td>
					<td name="16" onClick="javascript:checkClick(this.style);">&</td>
					<td name="17" onClick="javascript:checkClick(this.style);">&</td>
					<td name="18" onClick="javascript:checkClick(this.style);">&</td>
					<td name="19" onClick="javascript:checkClick(this.style);">&</td>
				</tr>
				<tr>
					<td name="20" onClick="javascript:checkClick(this.style);">&</td>
					<td name="21" onClick="javascript:checkClick(this.style);">&</td>
					<td name="22" onClick="javascript:checkClick(this.style);">&</td>
					<td name="23" onClick="javascript:checkClick(this.style);">&</td>
					<td name="24" onClick="javascript:checkClick(this.style);">&</td>
					<td name="25" onClick="javascript:checkClick(this.style);">&</td>
					<td name="26" onClick="javascript:checkClick(this.style);">&</td>
					<td name="27" onClick="javascript:checkClick(this.style);">&</td>
					<td name="28" onClick="javascript:checkClick(this.style);">&</td>
					<td name="29" onClick="javascript:checkClick(this.style);">&</td>
				</tr>
				<tr>
					<td name="30" onClick="javascript:checkClick(this.style);">&</td>
					<td name="31" onClick="javascript:checkClick(this.style);">&</td>
					<td name="32" onClick="javascript:checkClick(this.style);">&</td>
					<td name="33" onClick="javascript:checkClick(this.style);">&</td>
					<td name="34" onClick="javascript:checkClick(this.style);">&</td>
					<td name="35" onClick="javascript:checkClick(this.style);">&</td>
					<td name="36" onClick="javascript:checkClick(this.style);">&</td>
					<td name="37" onClick="javascript:checkClick(this.style);">&</td>
					<td name="38" onClick="javascript:checkClick(this.style);">&</td>
					<td name="39" onClick="javascript:checkClick(this.style);">&</td>
				</tr>
				<tr>
					<td name="40" onClick="javascript:checkClick(this.style);">&</td>
					<td name="41" onClick="javascript:checkClick(this.style);">&</td>
					<td name="42" onClick="javascript:checkClick(this.style);">&</td>
					<td name="43" onClick="javascript:checkClick(this.style);">&</td>
					<td name="44" onClick="javascript:checkClick(this.style);">&</td>
					<td name="45" onClick="javascript:checkClick(this.style);">&</td>
					<td name="46" onClick="javascript:checkClick(this.style);">&</td>
					<td name="47" onClick="javascript:checkClick(this.style);">&</td>
					<td name="48" onClick="javascript:checkClick(this.style);">&</td>
					<td name="49" onClick="javascript:checkClick(this.style);">&</td>
				</tr>
				<tr>
					<td name="50" onClick="javascript:checkClick(this.style);">&</td>
					<td name="51" onClick="javascript:checkClick(this.style);">&</td>
					<td name="52" onClick="javascript:checkClick(this.style);">&</td>
					<td name="53" onClick="javascript:checkClick(this.style);">&</td>
					<td name="54" onClick="javascript:checkClick(this.style);">&</td>
					<td name="55" onClick="javascript:checkClick(this.style);">&</td>
					<td name="56" onClick="javascript:checkClick(this.style);">&</td>
					<td name="57" onClick="javascript:checkClick(this.style);">&</td>
					<td name="58" onClick="javascript:checkClick(this.style);">&</td>
					<td name="59" onClick="javascript:checkClick(this.style);">&</td>
				</tr>
				<tr>
					<td name="60" onClick="javascript:checkClick(this.style);">&</td>
					<td name="61" onClick="javascript:checkClick(this.style);">&</td>
					<td name="62" onClick="javascript:checkClick(this.style);">&</td>
					<td name="63" onClick="javascript:checkClick(this.style);">&</td>
					<td name="64" onClick="javascript:checkClick(this.style);">&</td>
					<td name="65" onClick="javascript:checkClick(this.style);">&</td>
					<td name="66" onClick="javascript:checkClick(this.style);">&</td>
					<td name="67" onClick="javascript:checkClick(this.style);">&</td>
					<td name="68" onClick="javascript:checkClick(this.style);">&</td>
					<td name="69" onClick="javascript:checkClick(this.style);">&</td>
				</tr>
				<tr>
					<td name="70" onClick="javascript:checkClick(this.style);">&</td>
					<td name="71" onClick="javascript:checkClick(this.style);">&</td>
					<td name="72" onClick="javascript:checkClick(this.style);">&</td>
					<td name="73" onClick="javascript:checkClick(this.style);">&</td>
					<td name="74" onClick="javascript:checkClick(this.style);">&</td>
					<td name="75" onClick="javascript:checkClick(this.style);">&</td>
					<td name="76" onClick="javascript:checkClick(this.style);">&</td>
					<td name="77" onClick="javascript:checkClick(this.style);">&</td>
					<td name="78" onClick="javascript:checkClick(this.style);">&</td>
					<td name="79" onClick="javascript:checkClick(this.style);">&</td>
				</tr>
				<tr>
					<td name="80" onClick="javascript:checkClick(this.style);">&</td>
					<td name="81" onClick="javascript:checkClick(this.style);">&</td>
					<td name="82" onClick="javascript:checkClick(this.style);">&</td>
					<td name="83" onClick="javascript:checkClick(this.style);">&</td>
					<td name="84" onClick="javascript:checkClick(this.style);">&</td>
					<td name="85" onClick="javascript:checkClick(this.style);">&</td>
					<td name="86" onClick="javascript:checkClick(this.style);">&</td>
					<td name="87" onClick="javascript:checkClick(this.style);">&</td>
					<td name="88" onClick="javascript:checkClick(this.style);">&</td>
					<td name="89" onClick="javascript:checkClick(this.style);">&</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
	  <td align="center">
		<form name="herwick" method="post" action="highscore.php">
			<table width="400" border="0" cellpadding="8" cellspacing="0">
				<tr>
					<td>&
					</td>
				</tr>
				<tr>
					<td align="left">
						[b]Punktzahl:[/b]<input name="txtScore" type="text" readonly style="width:50px" value=0 size="25" maxlength="20" readonly char="5">
					</td>
					<td align="center">
						<input type="button" name="btnStart" value="Start" onClick="javascipt:document.buzzy.btnStart.disabled = true;initialize();" style="width:75px">
					</td>
					<td align="right">
						[b]Zeit:[/b]<input name="txtTime" type="text"  readonly style="width:50px" value=30 size="25" maxlength="20" readonly char="5">
					</td>
				</tr>
				<tr>
					<td>
						[b]Name:[/b]<input name="name" type="text" maxlength="25">
					</td>
					<td>
						<input type="submit" name="Submit" value="Senden" style="width:75px">
					</td>
					<td>&
						
					</td>
				</tr>
			</table>
		</form>	
	  </td>
	</tr>
</table>
</body>
</html>
 
U

user11

Guest

Hi lomion

Alo wenn ich das richtig sehe musst du den teil hier ändern:

function checkClick(objBox1)
{
if(blnGameStarted)
{
objBox = objBox1;
if(objBox.backgroundColor == "red")
{
document.herwick.txtScore.value = eval(document.herwick.txtScore.value) + 1;
}
else
{
objBox.backgroundColor = "blue";
setTimeout('objBox.backgroundColor = "white"',200);
}
}
}

Kann mich aber auch irren.

Gruss user11
 

lomion

Aktives Mitglied

danke für die hilfe mefisto..ich werds gleich mal ausprobieren..meld mich dann wenns geklappt hat oder nicht..

lomion
 
Bilder bitte hier hochladen und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Antworten auf deine Fragen:
Neues Thema erstellen

Willkommen auf PSD-Tutorials.de

In unseren Foren vernetzt du dich mit anderen Personen, um dich rund um die Themen Fotografie, Grafik, Gestaltung, Bildbearbeitung und 3D auszutauschen. Außerdem schalten wir für dich regelmäßig kostenlose Inhalte frei. Liebe Grüße senden dir die PSD-Gründer Stefan und Matthias Petri aus Waren an der Müritz. Hier erfährst du mehr über uns.

Stefan und Matthias Petri von PSD-Tutorials.de

Nächster neuer Gratisinhalt

03
Stunden
:
:
25
Minuten
:
:
19
Sekunden

Neueste Themen & Antworten

Flatrate für Tutorials, Assets, Vorlagen

Zurzeit aktive Besucher

Keine Mitglieder online.

Statistik des Forums

Themen
174.479
Beiträge
2.578.001
Mitglieder
65.969
Neuestes Mitglied
_djpanda_
Oben