| (Web-) Design und webbasierte Sprachen Tipps & Tricks, Designabgleich, HTML & Javascript, Flash, ASP, PHP, Perl/CGI... |
Diskussion: Array ist in Funktion undefiniert?! im Forum (Web-) Design und webbasierte Sprachen, in der Kategorie Web, Network & Multimedia Palace; Anzeige Hey HaBo Es geht um folgenden Code: Code: var gewicht = new Array(46); gewicht[1]="Alf|509_Alex|582_Angie|482_Abby|426_Anton|571_Alice|322_"; gewicht[2]="Alf|507_Alex|544_Angie|464_Abby|417_Anton|553_Alice|338_"; gewicht[3]="Alf|520_Alex|550_Angie|459_Abby|414_Anton|570_Alice|340_"; gewicht[4]="Alf|0_Alex|632_Angie|498_Abby|470_Anton|665_Alice|375_"; gewicht[5]="Alf|0_Alex|698_Angie|563_Abby|534_Anton|733_Alice|433_"; gewicht[6]="Alf|0_Alex|793_Angie|670_Abby|620_Anton|840_Alice|502_"; ...
![]() |
| | #1 (permalink) |
| Array ist in Funktion undefiniert?! Anzeige Hey HaBo Es geht um folgenden Code: Code: var gewicht = new Array(46);
gewicht[1]="Alf|509_Alex|582_Angie|482_Abby|426_Anton|571_Alice|322_";
gewicht[2]="Alf|507_Alex|544_Angie|464_Abby|417_Anton|553_Alice|338_";
gewicht[3]="Alf|520_Alex|550_Angie|459_Abby|414_Anton|570_Alice|340_";
gewicht[4]="Alf|0_Alex|632_Angie|498_Abby|470_Anton|665_Alice|375_";
gewicht[5]="Alf|0_Alex|698_Angie|563_Abby|534_Anton|733_Alice|433_";
gewicht[6]="Alf|0_Alex|793_Angie|670_Abby|620_Anton|840_Alice|502_";
gewicht[7]="Alf|0_Alex|900_Angie|777_Abby|675_Anton|910_Alice|566_";
gewicht[8]="Alf|0_Alex|970_Angie|857_Abby|741_Anton|992_Alice|661_";
gewicht[9]="Alf|0_Alex|1051_Angie|944_Abby|797_Anton|1121_Alice|724_";
gewicht[10]="Alf|0_Alex|1150_Angie|1003_Abby|887_Anton|1210_Alice|761_";
gewicht[11]="Alf|0_Alex|1219_Angie|1073_Abby|951_Anton|1280_Alice|849_";
gewicht[12]="Alf|0_Alex|1376_Angie|1178_Abby|1054_Anton|1372_Alice|894_";
gewicht[13]="Alf|0_Alex|1453_Angie|1236_Abby|1104_Anton|1431_Alice|993_";
gewicht[14]="Alf|0_Alex|1504_Angie|1332_Abby|1186_Anton|1542_Alice|1029_";
gewicht[15]="Alf|0_Alex|1605_Angie|1468_Abby|1255_Anton|1605_Alice|1155_";
gewicht[16]="Alf|0_Alex|1730_Angie|1550_Abby|1390_Anton|1730_Alice|1172_";
gewicht[17]="Alf|0_Alex|1760_Angie|1609_Abby|1465_Anton|1874_Alice|1294_";
gewicht[18]="Alf|0_Alex|1865_Angie|1707_Abby|1565_Anton|1950_Alice|1360_";
gewicht[19]="Alf|0_Alex|1973_Angie|1853_Abby|1667_Anton|2065_Alice|1470_";
gewicht[20]="Alf|0_Alex|2072_Angie|1975_Abby|1702_Anton|2130_Alice|1530_";
gewicht[21]="Alf|0_Alex|2150_Angie|2062_Abby|1754_Anton|2265_Alice|1636_";
gewicht[22]="Alf|0_Alex|2250_Angie|2240_Abby|1906_Anton|2360_Alice|1770_";
gewicht[23]="Alf|0_Alex|2440_Angie|2330_Abby|2041_Anton|2401_Alice|1870_";
gewicht[24]="Alf|0_Alex|2642_Angie|2496_Abby|2104_Anton|2745_Alice|2015_";
gewicht[25]="Alf|0_Alex|2810_Angie|2650_Abby|2316_Anton|2950_Alice|2143_";
gewicht[26]="Alf|0_Alex|3112_Angie|2806_Abby|2450_Anton|3102_Alice|2250_";
gewicht[27]="Alf|0_Alex|3208_Angie|2930_Abby|2640_Anton|3230_Alice|2380_";
gewicht[28]="Alf|0_Alex|3370_Angie|3140_Abby|2776_Anton|3440_Alice|2501_";
gewicht[29]="Alf|0_Alex|3470_Angie|3330_Abby|2900_Anton|3520_Alice|2610_";
gewicht[30]="Alf|0_Alex|3720_Angie|3520_Abby|3050_Anton|3670_Alice|2803_";
gewicht[31]="Alf|0_Alex|3840_Angie|3520_Abby|3160_Anton|3788_Alice|2890_";
gewicht[32]="Alf|0_Alex|4060_Angie|3670_Abby|3460_Anton|4020_Alice|3066_";
gewicht[33]="Alf|0_Alex|4370_Angie|3900_Abby|3650_Anton|4350_Alice|3360_";
gewicht[34]="Alf|0_Alex|4470_Angie|3970_Abby|3660_Anton|4470_Alice|3370_";
gewicht[35]="Alf|0_Alex|4640_Angie|4144_Abby|3702_Anton|4706_Alice|3450_";
gewicht[36]="Alf|0_Alex|4722_Angie|4220_Abby|3805_Anton|4802_Alice|3570_";
gewicht[37]="Alf|0_Alex|4950_Angie|4480_Abby|4014_Anton|5070_Alice|3720_";
gewicht[38]="Alf|0_Alex|5180_Angie|4770_Abby|4158_Anton|5168_Alice|3866_";
gewicht[39]="Alf|0_Alex|5410_Angie|4960_Abby|4330_Anton|5530_Alice|4120_";
gewicht[40]="Alf|0_Alex|5630_Angie|5150_Abby|4500_Anton|5760_Alice|4250_";
gewicht[41]="Alf|0_Alex|5900_Angie|5360_Abby|4700_Anton|6000_Alice|4378_";
gewicht[42]="Alf|0_Alex|6000_Angie|5500_Abby|4920_Anton|6000_Alice|4540_";
gewicht[43]="Alf|0_Alex|6000_Angie|5606_Abby|5060_Anton|6000_Alice|4560_";
gewicht[44]="Alf|0_Alex|6000_Angie|5880_Abby|5340_Anton|6000_Alice|4880_";
gewicht[45]="Alf|0_Alex|6000_Angie|5920_Abby|5515_Anton|6000_Alice|4890_";
var hundenamen = "Abby|Alex|Alf|Alice|Angie|Anton|";
var oldDay = -1;
function saveDay(day){
if(day == -1) return;
var hunde = hundenamen.split("|");
var saveString = "";
for each (var hund in hunde){
if(!hund || hund == "") continue;
gewicht = document.getElementsByName(hund).item(0).value;
saveString+=hund+"|"+gewicht+"_";
}
gewicht[day] = saveString;
}
function loadDay(day){
if(day == -1) return;
var hunde = hundenamen.split("|");
alert("loaded:"+gewicht[day]+"(Tag "+day+")");
var hund_gewicht = gewicht[day].split("_");
for each(var aDog in hund_gewicht){
var info = aDog.split("|");
document.getElementsByName(info[0]).item(0).value = info[1];
}
}
function dayChanged(){
saveDay(oldDay);
loadDay(document.getElementsByName("tagNummer").item(0).value);
oldDay = document.getElementsByName("tagNummer").item(0).value;
} Code: alert("loaded:"+gewicht[day]+"(Tag "+day+")"); bei Code: var hund_gewicht = gewicht[day].split("_"); Dabei steht ganz oben doch Code: var gewicht = new Array(46); gewicht[1]="Alf|509_Alex|582_Angie|482_Abby|426_Anton|571_Alice|322_"; ... Danke schon mal im voraus =)
__________________ Be the source always with you. | |
| | |
| | #2 (permalink) |
| Member of Honour ![]() Registriert seit: 02.10.01 ![]() Likes: 0 | Du übergibst das Array ja auch nicht an die entsprechende Funktion. Daher kann es dort auch nicht verfügbar sein. |
| | |
| HaBOT | - Anzeige - |
| |
| | #3 (permalink) | |
| Themenstarter | Zitat:
Wenn das so wäre wie du meinst, wieso kann ich dann auf Hundenamen zugreifen? EDIT: Ich habs nun halbwechs am laufen, ich habe zwar immer noch kein Plan, wieso es nich gefunzt hat.. aber jetzt hab ich eine weitere "Anormalie" Code: var gewicht = new Array("","Alf|509_Alex|582_Angie|482_Abby|426_Anton|571_Alice|322_",
"Alf|507_Alex|544_Angie|464_Abby|417_Anton|553_Alice|338_",
"Alf|520_Alex|550_Angie|459_Abby|414_Anton|570_Alice|340_",
"Alf|0_Alex|632_Angie|498_Abby|470_Anton|665_Alice|375_",
"Alf|0_Alex|698_Angie|563_Abby|534_Anton|733_Alice|433_",
"Alf|0_Alex|793_Angie|670_Abby|620_Anton|840_Alice|502_",
"Alf|0_Alex|900_Angie|777_Abby|675_Anton|910_Alice|566_",
"Alf|0_Alex|970_Angie|857_Abby|741_Anton|992_Alice|661_",
"Alf|0_Alex|1051_Angie|944_Abby|797_Anton|1121_Alice|724_",
"Alf|0_Alex|1150_Angie|1003_Abby|887_Anton|1210_Alice|761_",
"Alf|0_Alex|1219_Angie|1073_Abby|951_Anton|1280_Alice|849_",
"Alf|0_Alex|1376_Angie|1178_Abby|1054_Anton|1372_Alice|894_",
"Alf|0_Alex|1453_Angie|1236_Abby|1104_Anton|1431_Alice|993_",
"Alf|0_Alex|1504_Angie|1332_Abby|1186_Anton|1542_Alice|1029_",
"Alf|0_Alex|1605_Angie|1468_Abby|1255_Anton|1605_Alice|1155_",
"Alf|0_Alex|1730_Angie|1550_Abby|1390_Anton|1730_Alice|1172_",
"Alf|0_Alex|1760_Angie|1609_Abby|1465_Anton|1874_Alice|1294_",
"Alf|0_Alex|1865_Angie|1707_Abby|1565_Anton|1950_Alice|1360_",
"Alf|0_Alex|1973_Angie|1853_Abby|1667_Anton|2065_Alice|1470_",
"Alf|0_Alex|2072_Angie|1975_Abby|1702_Anton|2130_Alice|1530_",
"Alf|0_Alex|2150_Angie|2062_Abby|1754_Anton|2265_Alice|1636_",
"Alf|0_Alex|2250_Angie|2240_Abby|1906_Anton|2360_Alice|1770_",
"Alf|0_Alex|2440_Angie|2330_Abby|2041_Anton|2401_Alice|1870_",
"Alf|0_Alex|2642_Angie|2496_Abby|2104_Anton|2745_Alice|2015_",
"Alf|0_Alex|2810_Angie|2650_Abby|2316_Anton|2950_Alice|2143_",
"Alf|0_Alex|3112_Angie|2806_Abby|2450_Anton|3102_Alice|2250_",
"Alf|0_Alex|3208_Angie|2930_Abby|2640_Anton|3230_Alice|2380_",
"Alf|0_Alex|3370_Angie|3140_Abby|2776_Anton|3440_Alice|2501_",
"Alf|0_Alex|3470_Angie|3330_Abby|2900_Anton|3520_Alice|2610_",
"Alf|0_Alex|3720_Angie|3520_Abby|3050_Anton|3670_Alice|2803_",
"Alf|0_Alex|3840_Angie|3520_Abby|3160_Anton|3788_Alice|2890_",
"Alf|0_Alex|4060_Angie|3670_Abby|3460_Anton|4020_Alice|3066_",
"Alf|0_Alex|4370_Angie|3900_Abby|3650_Anton|4350_Alice|3360_",
"Alf|0_Alex|4470_Angie|3970_Abby|3660_Anton|4470_Alice|3370_",
"Alf|0_Alex|4640_Angie|4144_Abby|3702_Anton|4706_Alice|3450_",
"Alf|0_Alex|4722_Angie|4220_Abby|3805_Anton|4802_Alice|3570_",
"Alf|0_Alex|4950_Angie|4480_Abby|4014_Anton|5070_Alice|3720_",
"Alf|0_Alex|5180_Angie|4770_Abby|4158_Anton|5168_Alice|3866_",
"Alf|0_Alex|5410_Angie|4960_Abby|4330_Anton|5530_Alice|4120_",
"Alf|0_Alex|5630_Angie|5150_Abby|4500_Anton|5760_Alice|4250_",
"Alf|0_Alex|5900_Angie|5360_Abby|4700_Anton|6000_Alice|4378_",
"Alf|0_Alex|6000_Angie|5500_Abby|4920_Anton|6000_Alice|4540_",
"Alf|0_Alex|6000_Angie|5606_Abby|5060_Anton|6000_Alice|4560_",
"Alf|0_Alex|6000_Angie|5880_Abby|5340_Anton|6000_Alice|4880_",
"Alf|0_Alex|6000_Angie|5920_Abby|5515_Anton|6000_Alice|4890_");
var hundenamen = "Abby|Alex|Alf|Alice|Angie|Anton|";
var oldDay = -1;
function saveDay(day){
if(day == -1) return;
var hunde = hundenamen.split("|");
var saveString = "";
for each (var hund in hunde){
if(!hund || hund == "") continue;
gewicht = document.getElementsByName(hund).item(0).value;
saveString+=hund+"|"+gewicht+"_";
}
alert("gewicht("+day+") = "+saveString);
return;
gewicht[day] = saveString;
}
function loadDay(day){
if(day == -1) return;
var hunde = hundenamen.split("|");
alert("Gewicht an Tag "+day+":"+gewicht[day]);
var hund_gewicht = gewicht[day].split("_");
for each(var aDog in hund_gewicht){
if(!aDog || aDog == "") continue;
var info = aDog.split("|");
if(document.getElementsByName(info[0]).item(0) == 0 || document.getElementsByName(info[0]).item(0) == "" || info[0] == "" || !info[0]) {
return;
}
document.getElementsByName(info[0]).item(0).value = info[1];
}
}
function dayChanged(){
saveDay(oldDay);
loadDay(document.getElementsByName("tagNummer").item(0).value);
oldDay = document.getElementsByName("tagNummer").item(0).value;
}
function savePostData(){
document.getElementsByName("data").item(0).value = gewicht.join("$");
} Javascript bringt mich echt noch zur Verzweiflung =/
__________________ Be the source always with you. | |
| | |
| | #4 (permalink) |
| Moderator ![]() Registriert seit: 19.06.06 ![]() ![]() ![]() Likes: 52 | Also ich bekomme bei deinem Code folgendes zurück: loaded:Alf|0_Alex|1219_Angie|1073_Abby|951_Anton|1 280_Alice|849_(Tag 11) Die Fehlerkonsole gibt mir gleichzeitig Fehler: document.getElementsByName(info[0]).item(0) is null Ich kann dir zwar jetzt auch nicht so schnell sagen, woran es liegen kann, aber es scheint ein anderer Fehler zu sein, als was du gerade untersuchst |
| | |
| | #5 (permalink) | |
| Themenstarter | Zitat:
document.getElementsByName(info[0]).item(0) == 0 || document.getElementsByName(info[0]).item(0) == "" || info[0] == "" || !info[0] okay, ich versuch erstmal heute abend den Fehler wegzubekommen, bin jetzt Arbeiten. Danke schonmal
__________________ Be the source always with you. | |
| | |
| | #6 (permalink) | ||
| Moderator ![]() Registriert seit: 19.06.06 ![]() ![]() ![]() Likes: 52 | Zitat:
Bei dem aktuellen Code bekomme ich Gewicht an Tag 11:Alf|0_Alex|1219_Angie|1073_Abby|951_Anton|1280_ Alice|849_ und ich habe in der Fehlerkonsole keinen Eintrag mehr. Interessanterweise kommt bei der neuen Zeile aber ein false, so dass ich nicht das return nehme sondern doch wieder die vorhin noch beanstandete Zeile ausführe. | ||
| | |
| | #7 (permalink) |
| Themenstarter | Also ist der Fehler noch nicht gefunden.. =/ Ich fummel mal was weiter am Script rum, falls jemanden noch was einfällt, worans liegen könnte, sag bitte bescheid^^ EDIT: Also nachdem saveDay(); aufgerufen wird, ist gewicht in loadDay() = Gewicht von Anton am letzt ausgewähltem Tag?!?!?.. oO Javascript-Anomalie?! -.-' ?( ![]() EDIT2: Nein, mensch bin ich doof.. Das ist keine "Javascript-Anomalie", sondern in funktion saveDay(): Code: gewicht = document.getElementsByName(hund).item(0).value; Danke Trotzdem ^^
__________________ Be the source always with you. |
| | |
![]() |
| - Anzeige - | |
| |
| Themen-Optionen | |
| Ansicht | |
| |
Ähnliche Themen | ||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| php curl array string zu array parsen | b4ck | (Web-) Design und webbasierte Sprachen | 5 | 12.12.07 17:11 |
| Element aus String-Array an Funktion übergeben | CentralWay | Code Kitchen | 1 | 04.10.07 19:27 |
| Funktion: Bild in 2-D Array (Hex-Werte) | CentralWay | Code Kitchen | 7 | 23.05.07 15:35 |
| Funktion zum prüfen ob Funktion erlaubt ist | Chatter | (Web-) Design und webbasierte Sprachen | 5 | 21.01.07 14:11 |
| C int array[n] zu x int ??? | NeoN | Code Kitchen | 11 | 25.04.04 20:38 |