• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

probleme mit setTimeout

Paix

Neues Mitglied
Hi leute ich habe mal ne kleine spielerei aufgebaut. benutze ich die funktion video. changeColor2(myArray); funktioniert alles wunderbar, wenn aber setTimeout ("changeColor2(myArray2)", 1000); kommt, kriege ich da ne fehlermeldung. Kann mir da jemand weiterhelfen?

gruß kay

HTML:
<script type="text/javascript">

function changeColor(color) {
  document.getElementById("Tabelle1").style.backgroundColor = color;
  document.getElementById("Tabelle2").style.backgroundColor = color;
  document.getElementById("Tabelle3").style.backgroundColor = color;
  document.getElementById("Tabelle4").style.backgroundColor = color;
  document.getElementById("Tabelle5").style.backgroundColor = color;
  document.getElementById("Tabelle6").style.backgroundColor = color;
  document.getElementById("Tabelle7").style.backgroundColor = color;
  document.getElementById("Tabelle8").style.backgroundColor = color;
  document.getElementById("Tabelle9").style.backgroundColor = color;
 }
function changeColor2(myArray) 
{
  document.getElementById("Tabelle1").style.backgroundColor = myArray[0];
  document.getElementById("Tabelle2").style.backgroundColor = myArray[1];
  document.getElementById("Tabelle3").style.backgroundColor = myArray[2];
  document.getElementById("Tabelle4").style.backgroundColor = myArray[3];
  document.getElementById("Tabelle5").style.backgroundColor = myArray[4];
  document.getElementById("Tabelle6").style.backgroundColor = myArray[5];
  document.getElementById("Tabelle7").style.backgroundColor = myArray[6];
  document.getElementById("Tabelle8").style.backgroundColor = myArray[7];
  document.getElementById("Tabelle9").style.backgroundColor = myArray[8];

}
function video() 
{
 var myArray;
 var farben = document.getElementById("P1_TEST").value;
 myArray = farben.split("#");
 
 var myArray2;
 var farben2 = document.getElementById("P2_TEST").value;
 myArray2 = farben2.split("#");
 
changeColor2(myArray);
setTimeout ("changeColor2(myArray2)", 1000);
}
 </script>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Unbenanntes Dokument</title>
</head>

<body>
<table width="100" height="100">
<tr>
<td id="Tabelle1"></a></td>
<td id="Tabelle2"></a></td>
<td id="Tabelle3"></a></td>
</tr>
 <tr>
<td id="Tabelle4"></a></td>
<td id="Tabelle5"></a></td>
<td id="Tabelle6"></a></td>
</tr>
 <tr>
<td id="Tabelle7"></a></td>
<td id="Tabelle8"></a></td>
<td id="Tabelle9"></a></td>
</tr></table>

<table id="apex_layout_6034213329983716" border="0" class="formlayout" summary="" ><td></td><td  colspan="1" rowspan="1" align="left"><input type="hidden" name="p_arg_names" value="6037918832382661" /><input type="hidden" id="P1_TEST" name="p1_t04" value="blue#red#yellow#green#black#white#green#yellow#red" /></td>
</table>
<table id="apex_layout_6034213329983716" border="0" class="formlayout" summary="" ><td></td><td  colspan="1" rowspan="1" align="left"><input type="hidden" name="p_arg_names1" value="6037918832382661" /><input type="hidden" id="P2_TEST" name="p2_t04" value="red#red#red#red#red#red#red#red#red" /></td>
</table>
<table id="apex_layout_6034213329983716" border="0" class="formlayout" summary="" ><td></td><td  colspan="1" rowspan="1" align="left"><input type="hidden" name="p_arg_names2" value="6037918832382661" /><input type="hidden" id="P3_TEST" name="p3_t04" value="blue#red#yellow#green#black#white#green#yellow#red" /></td>
</table>
<table id="apex_layout_6034213329983716" border="0" class="formlayout" summary="" ><td></td><td  colspan="1" rowspan="1" align="left"><input type="hidden" name="p_arg_names3" value="6037918832382661" /><input type="hidden" id="P4_TEST" name="p4_t04" value="blue#red#yellow#green#black#white#green#yellow#red" /></td>
</table>
<table id="apex_layout_6034213329983716" border="0" class="formlayout" summary="" ><td></td><td  colspan="1" rowspan="1" align="left"><input type="hidden" name="p_arg_names4" value="6037918832382661" /><input type="hidden" id="P5_TEST" name="p5_t04" value="blue#blue#blue#blue#blue#blue#blue#blue#blue" /></td>
</table>

<input type="button" name="Text 1" value="GRÜN"
      onclick="changeColor('green')">
<input type="button" name="Text 1" value="GELB"
      onclick="changeColor('yellow')">
<input type="button" name="Text 1" value="BLAU"
      onclick="changeColor('blue')">
<input type="button" name="Text 1" value="ROT"
      onclick="changeColor('red')">
<input type="button" name="Text 1" value="SCHWARZ"
      onclick="changeColor('black')">
<input type="button" name="Text 1" value ="Video" 
      onclick="video()">



</body>
</html>
 
Er hat Probleme mit der Variable. Probier es mal so:
Code:
setTimeout (function() { changeColor2(myArray2); })", 1000);
 
Super, der tip war gold wert. zwar lief es nicht copy/paste, aber nach ein bißchen probieren hat es geklappt.
Code:
setTimeout (function() { changeColor2(myArray2) }, 1000);
 
Zurück
Oben