@LASTEDIT:
Habs nun auch so geschafft
Wer will kann es haben...
http://www.xup.in/dl,12604266/4gewinnt.rar/
~close bitte~
-----------------------
Hallo,
mein Problem ist, dass ich mit getElementById bzw. über document.FORMNAME.ELENAME.value etwas verändern möchte... vor 2 Wochen habe ich mir ein Script geschrieben, das eine Auswertung macht... Hier mal das Script und das wichtigste in Rot
Unten ist zu sehen, das ich mit onclick die function "showhidebenotung" aufrufe. In der Funktion selber, ändere ich dann die sichtbarkeit des Buttons ganz unten!PHP-Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script language="javascript">
var zahl = 0, counter = 0;
function showhide(divid)
{
obj = document.getElementById(divid);
obj.style.display = obj.style.display == 'none' ? 'block' : 'none';
}
function showhidebenotung(wert)
{
obj1 = document.getElementById('informatik'); //info
obj2 = document.getElementById('elektro'); //eletro
obj3 = document.getElementById('bau'); //bau
obj4 = document.getElementById('mecha'); //mecha
obj5 = document.getElementById('maschinen'); //mashcinen
zahl = 0;
document.getElementById('absenden').style.display = 'none';
[color=red] document.anmeldung.absen.disabled = true;[/color]
counter = 0;
if(wert == '1')
{
obj1.style.display = 'block';
obj2.style.display = 'none';
obj3.style.display = 'none';
obj4.style.display = 'none';
obj5.style.display = 'none';
}
if(wert == '2')
{
obj1.style.display = 'none';
obj2.style.display = 'block';
obj3.style.display = 'none';
obj4.style.display = 'none';
obj5.style.display = 'none';
}
if(wert == '3')
{
obj2.style.display = 'none';
obj1.style.display = 'none';
obj3.style.display = 'block';
obj4.style.display = 'none';
obj5.style.display = 'none';
}
if(wert == '4')
{
obj4.style.display = 'block';
obj2.style.display = 'none';
obj3.style.display = 'none';
obj1.style.display = 'none';
obj5.style.display = 'none';
}
if(wert == '5')
{
obj5.style.display = 'block';
obj2.style.display = 'none';
obj3.style.display = 'none';
obj4.style.display = 'none';
obj1.style.display = 'none';
}
}
function auswertung(wert, count)
{
counter += count;
zahl += wert;
if(counter > 4)
{
if(zahl >= 13)
{
document.getElementById('absenden').style.display = 'block';
document.getElementById('fehlerc').style.display = 'none';
document.anmeldung.absen.disabled = false;
}
else
{
if(counter >= 5 && zahl < 13 && zahl > 4)
{
document.getElementById('fehlerc').style.display = 'block';
document.getElementById('absenden').style.display = 'block';
document.anmeldung.absen.disabled = true;
}
}
}
}
</script>
<meta name="author" content="permA">
<meta name="editor" content="html-editor phase 5">
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000">
<form[color=red] name="anmeldung" [/color]action="http://www.rdf100.de/" method="post">
<div id="ba" style="display:block;">
Haben Sie eine berufliche Erstausbildung erfolgreich abgelegt?<br>
Ja <input type="radio" name="bea" value="1" onclick="showhide('ba'),showhide('bf');"> -- nein
<input type="radio" name="bea" value="2" onclick="showhide('fehlera'),showhide('be'),showhide('ba')">
</div>
<div id="fehlerc" style="display:none;">
<font color="red" size="-1">Sie haben nicht die nötige Erfahrung...<br>Selbst wenn Sie jetzt die Angaben wieder ändern, werden Sie es wärend der Ausbildung nicht leichter haben...</font>
</div>
<div id="fehlera" style="display:none;">
<font color="red" size="-1">Sie haben nicht die nötigen Voraussetzungen, jedoch mit einer 7-jährigen Berufserfahrung, ist die auszugleichen.</font>
</div>
<div id="be" style="display:none;">
Haben Sie mindestens 7 Jahre in einem Beruf aus dem Berufsfeld der gewünschten Fachrichtung gearbeitet?<br>
Ja <input type="radio" name="bee" value="1" onclick="showhide('be'),showhide('benotung'),showhide('fehlera');"> -- nein
<input type="radio" name="bee" value="2" onclick="showhide('fehlerb'),showhide('be'),showhide('fehlera');">
</div>
<div id="fehlerb" style="display:none;">
<font color="red" size="-1">Ihnen fehlen die Voraussetzungen für die Technickerweiterbildung!</font>
</div>
<div id="bf" style="display:none;">
Haben Sie mindestens 1 Jahr praktisch im Berufsfeld ihres Ausbildungsberufs gearbeitet?<br>
Ja <input type="radio" name="bef" value="1" onclick="showhide('bf'),showhide('benotung');"> -- nein
<input type="radio" name="bef" value="2" onclick="showhide('bf'),showhide('fehlerb');">
</div>
<div id="benotung" style="display:none;z-index:1;">
Verfügen Sie über gute Kenntnisse in den Lerngebieten? Bewerten Sie ihre Kenntnisse durch Vergabe von max 5 Punkten!<br>
<br>
<select name="bz" size="1">
[color=red]<option onclick="showhidebenotung('1')">Informatik</option>[/color]
<option onclick="showhidebenotung('2')">Elektrotechnik</option>
<option onclick="showhidebenotung('3')">Bautechnik</option>
<option onclick="showhidebenotung('4')">Mechatronik</option>
<option onclick="showhidebenotung('5')">Maschinenbautechnik</option>
</select>
<br><br>
<?php include("faecher.php") ?>
<br><br>
</div>
[color=red]
<div id="absenden" style="display:none;">
<input type="submit" value="Absenden" name="absen">
</div>
[/color]
</form>
</body>
</html>
Wie ihr merkt, habe ich eine eigenschaft bearbeitet, wo dem Browser garnicht das element dazu bekannt ist...Wieso ich den gedanken habe?
Liegt an meinem neuen Projekt...
Ein 4 gewinnt.
Hier der Code:
Hier der Fehler von FireFox: "document.vier unbekannt"PHP-Code:<!-- Ein 4 gewinnt...
Autor: -------------
Datum: Pfingstferien 2010
Status: PROBLEM BEIM FINDEN DER ELEMENTE, OBWOHL ES in ueb3.php ja auch wunderbar geklappt hat, die eigenschaft eines elements (vor deren anzeige) zu verändern (obwohl eigentlich nciht bekannt)
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Eine kleine Runde 4 gewinnt?</title>
<style type="text/css">
div.pfeil{
background-image:url(pics/pfeil.gif);
background-repeat:no-repeat;
background-position:center center;
width:57px;
height:57px;
border:0px solid #000000;
float:left;
}
</style>
<script language="javascript">
var counter = 0;
var spielfeld = new Array(6);
spielfeld[0] = new Array(0,0,0,0,0,0,0);
spielfeld[1] = new Array(0,0,0,0,0,0,0);
spielfeld[2] = new Array(0,0,0,0,0,0,0);
spielfeld[3] = new Array(0,0,0,0,0,0,0);
spielfeld[4] = new Array(0,0,0,0,0,0,0);
spielfeld[5] = new Array(0,0,0,0,0,0,0);
//0 = Feld leer
//1 = Spieler 1
//2 = Spieler 2
//document.write(spielfeld[0][0] + " - " + spielfeld[0][6]); //Ausgabe = 0 - 6
//spielfeld[ZEILE][SPALTE]
function einwurf(spalte)
{
document.write("Counter: " + counter + "<br>Spalte: " + spalte);
var i = 5;
if(counter%2 == 0) //Spieler 1
{
while(spielfeld[i][spalte] != 0 && i > 0)
i--;
spielfeld[i][spalte] = 1;
}
else //Spieler 2
{
while(spielfeld[i][spalte] != 0 && i > 0)
i++;
spielfeld[i][spalte] = 2;
}
counter++;
//showhide('pla1');
//showhide('pla2');
pruefen();
}
function pruefen()
{
for(var i = 0; i < 6; i++)
{
if(spielfeld[0][i] != 0) //Wenn Spalte voll, dann button value = X und disabled
{
switch(i)
{
[color=red]case 0: document.vier.p0.value = 'X';
document.vier.p0.disabled = true;
break;
case 1: document.vier.p1.value = 'X';
document.vier.p1.disabled = true;
break;
case 2: document.vier.p2.value = 'X';
document.vier.p2.disabled = true;
break;
case 3: document.vier.p3.value = 'X';
document.vier.p3.disabled = true;
break;
case 4: document.vier.p4.value = 'X';
document.vier.p4.disabled = true;
break;
case 5: document.vier.p5.value = 'X';
document.vier.p5.disabled = true;
break;
case 6: document.vier.p6.value = 'X';
document.vier.p6.disabled = true;
break;[/color]
}
}
else
{
switch(i)
{
[color=red]case 0: document.vier.p0.value = 'V';
document.vier.p0.disabled = false;
break;
case 1: document.vier.p1.value = 'V';
document.vier.p1.disabled = false;
break;
case 2: document.vier.p2.value = 'V';
document.vier.p2.disabled = false;
break;
case 3: document.vier.p3.value = 'V';
document.vier.p3.disabled = false;
break;
case 4: document.vier.p4.value = 'V';
document.vier.p4.disabled = false;
break;
case 5: document.vier.p5.value = 'V';
document.vier.p5.disabled = false;
break;
case 6: document.vier.p6.value = 'V';
document.vier.p6.disabled = false;
break;[/color]
}
}
}
}
function showhide(divid)
{
obj = document.getElementById(divid);
obj.style.display = obj.style.display == 'none' ? 'block' : 'none';
}
</script>
</head>
<meta name="author" content="Sven Schwab">
<meta name="editor" content="html-editor phase 5">
<body text="#000000" bgcolor="#F2EECB" link="#000000" alink="#000000" vlink="#000000">
<[color=red]form name="vier"[/color] action="#" method="post">
<br><br><br>
<div align="center">
<div id="pla1" style="display:block">Spieler 1 ist am zug...<br><br><br></div>
<div id="pla2" style="display:none">Spieler 2 ist am zug...<br><br><br></div>
<div id="haupt" style="background-image:url(pics/4gewinnt.gif);background-repeat:no-repeat;background-position:bottom;width:399px;height:399px;">
<!-- Pfeile -->
<div id="" class="pfeil" align="center"><input type="button" value="V" name="p0" onclick="Javascript:document.vier.p0.value = document.vier.p0.value == 'X' ? 'V' : 'X';showhide('pla1'); showhide('pla2');"></div>
<div id="" class="pfeil" align="center"><input type="button" value="V" name="p1" onclick=""></div>
[color=red]<div id="" class="pfeil" align="center"><input type="button" value="V" name="p2" onclick="einwurf('2');"></div>[/color]
<div id="" class="pfeil" align="center"><input type="button" value="V" name="p3" onclick="einwurf('3');"></div>
<div id="" class="pfeil" align="center"><input type="button" value="V" name="p4" onclick="einwurf('4');"></div>
<div id="" class="pfeil" align="center"><input type="button" value="V" name="p5" onclick="einwurf('5');"></div>
<div id="" class="pfeil" align="center"><input type="button" value="V" name="p6" onclick="einwurf('6');"></div>
<div id="" style="width:1px;height:1px;border:0px solid #000000;clear:both;"></div>
<!-- Spielfeld -->
<div id="aa" style="width:55px;height:55px;border:1px solid #000000;float:left;"></div>
<div id="ab" style="width:55px;height:55px;border:1px solid #000000;float:left;"></div>
<div id="ac" style="width:55px;height:55px;border:1px solid #000000;float:left;">
...
<div id="" style="width:1px;height:1px;border:0px solid #000000;clear:both;"></div><br>
</div>
</div>
<input type="submit" value="blub" disabled>
</form>
</body>
</html>
Script 1) Hier ändert er die Eigenschaft eines Elements, das weder vor Funktionsaufruf noch der Funktionsdeklaration bekannt ist.
Script 2) Hier macht er es nicht...
Ich komm langsam dem Ausraster immer näher
Wie ihr seht ist auch das Script noch lang nicht dem finale nahe. Deshalb auch bitte keine kommentare, warum bei einem button andere funktionsaufrufe stehen usw. ist ja alles noch testphase...
ich hoffe ihr findet euch auch in dem script zurecht ^^ ich muss nun schlafen, sonst platzt mein kopf...
falls ihr die bilder wollt, zum direkten betrachten:
@ZUsatz: script 2) ich kann die showhide funktion zum beispiel auch nur aufrufen, wenn ich es unter den gewünschten div-box's schreib. in der einwurf funktion klappt der aufruf wieder nicht... objekt zeigt auf NULL. da findet er sie dann auch nciht mehr.
jedoch bei dem script 1, klappt das wunderbar die showhide funktion egal wo auch immer aus, aufzurufen
-------------------------
@LASTEDIT:
Habs nun auch so geschafft
Wer will kann es haben...
http://www.xup.in/dl,12604266/4gewinnt.rar/
~close bitte~
Geändert von tenesto (24.05.2010 um 02:45 Uhr)
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)