dyn. Listenfeld unter Netscape 4.x
Johannes
- javascript
Folgendes Skript wird von Netscape 6.x aufwärts und vom IE ausgeführt, aber nicht von der Netscape 4.x:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title></title>
</head>
<script language="javascript" >
function caselection(){
var xy= new Array();
var de_areas = new Array();
de_areas["de1"] = "Baden-Württemberg";
de_areas["de2"] = "Bayern";
de_areas["de3"] = "Berlin";
de_areas["de4"] = "Brandenburg";
de_areas["de5"] = "Bremen";
de_areas["de6"] = "Hamburg";
de_areas["de7"] = "Hessen";
de_areas["de8"] = "Mecklenburg-Vorp.";
de_areas["de9"] = "Niedersachsen";
de_areas["de10"]= "Nordrhein-Westfalen";
de_areas["de11"]= "Rheinland-Pfalz";
de_areas["de12"]= "Saarland";
de_areas["de13"]= "Sachsen";
de_areas["de14"]= "Sachsen-Anhalt";
de_areas["de15"]= "Schleswig-Holstein";
de_areas["de16"]= "Thüringen";
var at_areas = new Array();
at_areas["at1"] = "Burgenland";
at_areas["at2"] = "Kärnten";
at_areas["at3"] = "Niederösterreich";
at_areas["at4"] = "Salzburg";
at_areas["at5"] = "Steiermark";
at_areas["at6"] = "Tirol";
at_areas["at7"] = "Vorarlberg";
at_areas["at8"] = "Wien";
var ch_areas = new Array();
ch_areas["ch1"] = "Aargau";
ch_areas["ch2"] = "Appenzell-Ausser-Rhoden";
ch_areas["ch3"] = "Appenzell-Inner-Rhoden";
ch_areas["ch4"] = "Basel-Land";
ch_areas["ch5"] = "Basel-Stadt";
ch_areas["ch6"] = "Bern";
ch_areas["ch7"] = "Fribourg";
ch_areas["ch8"] = "Genf";
ch_areas["ch9"] = "Glarus";
ch_areas["ch10"] = "Graubünden";
ch_areas["ch11"] = "Jura";
ch_areas["ch12"] = "Luzern";
ch_areas["ch13"] = "Neuchatel";
ch_areas["ch14"] = "Nidwalden";
ch_areas["ch15"] = "Obwalden";
ch_areas["ch16"] = "Schaffhausen";
ch_areas["ch17"] = "Schwyz";
ch_areas["ch18"] = "Solothurn";
ch_areas["ch19"] = "St. Gallen]";
ch_areas["ch20"] = "Thurgau";
ch_areas["ch21"] = "Tessin/Ticino";
ch_areas["ch22"] = "Uri";
ch_areas["ch23"] = "Vaud/Waadt";
ch_areas["ch24"] = "Valais/Wallis";
ch_areas["ch25"] = "Zug";
ch_areas["ch26"] = "Zürich";
if (document.ContriesAreasSearch.country.value=="de"){
//document.write("blabla");
counter = 0;
document.ContriesAreasSearch.areas.length = 0;
for (i in de_areas){
NewItem = new Option(de_areas[i],i,false,false);
document.ContriesAreasSearch.areas.options[counter] = NewItem;
counter = counter + 1;
}
}
if (document.ContriesAreasSearch.country.value=="at"){
counter = 0;
document.ContriesAreasSearch.areas.length = 0;
for (i in at_areas){
NewItem = new Option(at_areas[i],i,false,false);
document.ContriesAreasSearch.areas.options[counter] = NewItem;
counter = counter + 1;
}
}
if (document.ContriesAreasSearch.country.value=="ch"){
counter = 0;
document.ContriesAreasSearch.areas.length = 0;
for (i in ch_areas){
NewItem = new Option(ch_areas[i],i,false,false);
document.ContriesAreasSearch.areas.options[counter] = NewItem;
counter = counter + 1;
}
}
}
</script>
<body bgcolor="#ffffff" >
<form name="ContriesAreasSearch" method="post" action="test.php4">
<select name="country" size="1" onChange="caselection()">
<option value="de">Deutschland</option>
<option value="ch">Schweiz</option>
<option value="at">Österreich</option>
</select>
<br><br>
<select name="areas" size="1"><option></option></select>
</form>
</body>
</html>
Und zwar soll das 2. Listenfeld mit "areas" dynamisch in Abhängigkeit
vom 1. "country" erzeugt werden. An anderer Stelle im Forum habe ich etwa in der Art gelesen:
c = document.forms["countriesareasselection"].country;
wert = c.[c.selectecIndex].value;
Da steigt NS 4.x mit "javascript:" aus und meldet in der Konsole:
"document.forms["countriesareasselection"].country has no properties."
Wer weiss, wie das Skript passend für NS 4.x angepasst werden muß?
Vielen Dank für brauchbare Antworten.
Johannes
Hallo Johannes,
c = document.forms["countriesareasselection"].country;
^^^^^^^^^^^^^^^^^^^^^^^
Dieses Formular gibt es nicht. Dein Formular heißt CountriesAreaSearch.
wert = c.[c.selectecIndex].value;
^
Der Punkt ist hier zu viel.
Grüße,
Christian
Danke an Christian Seilert. Jetzt ist leider noch ein 2. Problem
aufgetreten. Und zwar zeigt mir jetzt die NS 4.x - Serie
im Listenfeld "areas" nur eine Option an. Und zwar immer nur die letzte. Vielleicht verrät mir jetzt noch einer, woran das liegt.
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title></title>
</head>
<script language="javascript" >
function caselection(){
var xy= new Array();
var de_areas = new Array();
de_areas["de1"] = "Baden-Württemberg";
de_areas["de2"] = "Bayern";
de_areas["de3"] = "Berlin";
de_areas["de4"] = "Brandenburg";
de_areas["de5"] = "Bremen";
de_areas["de6"] = "Hamburg";
de_areas["de7"] = "Hessen";
de_areas["de8"] = "Mecklenburg-Vorp.";
de_areas["de9"] = "Niedersachsen";
de_areas["de10"]= "Nordrhein-Westfalen";
de_areas["de11"]= "Rheinland-Pfalz";
de_areas["de12"]= "Saarland";
de_areas["de13"]= "Sachsen";
de_areas["de14"]= "Sachsen-Anhalt";
de_areas["de15"]= "Schleswig-Holstein";
de_areas["de16"]= "Thüringen";
var at_areas = new Array();
at_areas["at1"] = "Burgenland";
at_areas["at2"] = "Kärnten";
at_areas["at3"] = "Niederösterreich";
at_areas["at4"] = "Salzburg";
at_areas["at5"] = "Steiermark";
at_areas["at6"] = "Tirol";
at_areas["at7"] = "Vorarlberg";
at_areas["at8"] = "Wien";
var ch_areas = new Array();
ch_areas["ch1"] = "Aargau";
ch_areas["ch2"] = "Appenzell-Ausser-Rhoden";
ch_areas["ch3"] = "Appenzell-Inner-Rhoden";
ch_areas["ch4"] = "Basel-Land";
ch_areas["ch5"] = "Basel-Stadt";
ch_areas["ch6"] = "Bern";
ch_areas["ch7"] = "Fribourg";
ch_areas["ch8"] = "Genf";
ch_areas["ch9"] = "Glarus";
ch_areas["ch10"] = "Graubünden";
ch_areas["ch11"] = "Jura";
ch_areas["ch12"] = "Luzern";
ch_areas["ch13"] = "Neuchatel";
ch_areas["ch14"] = "Nidwalden";
ch_areas["ch15"] = "Obwalden";
ch_areas["ch16"] = "Schaffhausen";
ch_areas["ch17"] = "Schwyz";
ch_areas["ch18"] = "Solothurn";
ch_areas["ch19"] = "St. Gallen]";
ch_areas["ch20"] = "Thurgau";
ch_areas["ch21"] = "Tessin/Ticino";
ch_areas["ch22"] = "Uri";
ch_areas["ch23"] = "Vaud/Waadt";
ch_areas["ch24"] = "Valais/Wallis";
ch_areas["ch25"] = "Zug";
ch_areas["ch26"] = "Zürich";
c=document.forms['CountriesAreasSearch'].elements['country'];
if (c[c.selectedIndex].value=="de"){
counter = 0;
document.CountriesAreasSearch.areas.length = 0;
for (i in de_areas){
alert (de_areas[i]);
NewItem = new Option(de_areas[i],i,false,false);
document.CountriesAreasSearch.areas.options[counter] = NewItem;
counter = counter + 1;
}
}
if (c[c.selectedIndex].value=="at"){
counter = 0;
document.CountriesAreasSearch.areas.length = 0;
for (i in at_areas){
NewItem = new Option(at_areas[i],i,false,false);
document.CountriesAreasSearch.areas.options[counter] = NewItem;
counter = counter + 1;
}
}
if (c[c.selectedIndex].value=="ch"){
counter = 0;
document.CountriesAreasSearch.areas.length = 0;
for (i in ch_areas){
NewItem = new Option(ch_areas[i],i,false,false);
document.CountriesAreasSearch.areas.options[counter] = NewItem;
counter = counter + 1;
}
}
}
</script>
<body bgcolor="#ffffff" >
<form name="CountriesAreasSearch" method="post" action="test.php4">
<select name="country" size="1" onChange="caselection()">
<option value="de">Deutschland</option>
<option value="ch">Schweiz</option>
<option value="at">Österreich</option>
</select>
<br><br>
<select name="areas" size="1"></select>
</form>
</body>
</html>
Hallo Johannes,
Danke an Christian Seilert. Jetzt ist leider noch ein 2. Problem
aufgetreten. Und zwar zeigt mir jetzt die NS 4.x - Serie
im Listenfeld "areas" nur eine Option an. Und zwar immer nur die letzte. Vielleicht verrät mir jetzt noch einer, woran das liegt.
Vmtl. liegt das an der Art, wie Du die Elemente einfügst. Schau' Dir mal http://www.xs4all.nl/~ppk/js/options.html an - das funktioniert auch im Netscape 4.
Grüße,
Christian
Danke! Jetzt funktioniert's mit:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title></title>
</head>
<script language="javascript" >
function caselection(){
var xy= new Array();
var de_areas = new Array();
de_areas["de1"] = "Baden-Württemberg";
de_areas["de2"] = "Bayern";
de_areas["de3"] = "Berlin";
de_areas["de4"] = "Brandenburg";
de_areas["de5"] = "Bremen";
de_areas["de6"] = "Hamburg";
de_areas["de7"] = "Hessen";
de_areas["de8"] = "Mecklenburg-Vorp.";
de_areas["de9"] = "Niedersachsen";
de_areas["de10"]= "Nordrhein-Westfalen";
de_areas["de11"]= "Rheinland-Pfalz";
de_areas["de12"]= "Saarland";
de_areas["de13"]= "Sachsen";
de_areas["de14"]= "Sachsen-Anhalt";
de_areas["de15"]= "Schleswig-Holstein";
de_areas["de16"]= "Thüringen";
var at_areas = new Array();
at_areas["at1"] = "Burgenland";
at_areas["at2"] = "Kärnten";
at_areas["at3"] = "Niederösterreich";
at_areas["at4"] = "Salzburg";
at_areas["at5"] = "Steiermark";
at_areas["at6"] = "Tirol";
at_areas["at7"] = "Vorarlberg";
at_areas["at8"] = "Wien";
var ch_areas = new Array();
ch_areas["ch1"] = "Aargau";
ch_areas["ch2"] = "Appenzell-Ausser-Rhoden";
ch_areas["ch3"] = "Appenzell-Inner-Rhoden";
ch_areas["ch4"] = "Basel-Land";
ch_areas["ch5"] = "Basel-Stadt";
ch_areas["ch6"] = "Bern";
ch_areas["ch7"] = "Fribourg";
ch_areas["ch8"] = "Genf";
ch_areas["ch9"] = "Glarus";
ch_areas["ch10"] = "Graubünden";
ch_areas["ch11"] = "Jura";
ch_areas["ch12"] = "Luzern";
ch_areas["ch13"] = "Neuchatel";
ch_areas["ch14"] = "Nidwalden";
ch_areas["ch15"] = "Obwalden";
ch_areas["ch16"] = "Schaffhausen";
ch_areas["ch17"] = "Schwyz";
ch_areas["ch18"] = "Solothurn";
ch_areas["ch19"] = "St. Gallen]";
ch_areas["ch20"] = "Thurgau";
ch_areas["ch21"] = "Tessin/Ticino";
ch_areas["ch22"] = "Uri";
ch_areas["ch23"] = "Vaud/Waadt";
ch_areas["ch24"] = "Valais/Wallis";
ch_areas["ch25"] = "Zug";
ch_areas["ch26"] = "Zürich";
c=document.forms['CountriesAreasSearch'].elements['country'];
if (c[c.selectedIndex].value=="de"){
counter = 0;
box = document.forms['CountriesAreasSearch'].elements['areas'];
while (box.options.length) box.options[0] = null;
//document.CountriesAreasSearch.areas.length = 0;
//document.auswahl.schlagwort.options[0] = NeuerEintrag;
for (i in de_areas){
alert (de_areas[i]);
NewItem = new Option(de_areas[i],i,false,false);
document.forms['CountriesAreasSearch'].elements['areas'].options[counter] = NewItem;
counter = counter + 1;
}
}
if (c[c.selectedIndex].value=="at"){
counter = 0;
//document.CountriesAreasSearch.areas.length = 0;
box = document.forms['CountriesAreasSearch'].elements['areas'];
while (box.options.length) box.options[0] = null;
for (i in at_areas){
NewItem = new Option(at_areas[i],i,false,false);
document.forms['CountriesAreasSearch'].elements['areas'].options[counter] = NewItem;
counter = counter + 1;
}
}
if (c[c.selectedIndex].value=="ch"){
counter = 0;
//document.CountriesAreasSearch.areas.length = 0;
box = document.forms['CountriesAreasSearch'].elements['areas'];
while (box.options.length) box.options[0] = null;
for (i in ch_areas){
NewItem = new Option(ch_areas[i],i,false,false);
document.forms['CountriesAreasSearch'].elements['areas'].options[counter] = NewItem;
counter = counter + 1;
}
}
}
</script>
<body bgcolor="#ffffff" >
<form name="CountriesAreasSearch" method="post" action="test.php4">
<select name="country" size="1" onChange="caselection()">
<option value="de">Deutschland</option>
<option value="ch">Schweiz</option>
<option value="at">Österreich</option>
</select>
<br><br>
<select name="areas" size="1"></select>
</form>
</body>
</html>
Hallo Johannes,
Danke an Christian Seilert. Jetzt ist leider noch ein 2. Problem
aufgetreten. Und zwar zeigt mir jetzt die NS 4.x - Serie
im Listenfeld "areas" nur eine Option an. Und zwar immer nur die letzte. Vielleicht verrät mir jetzt noch einer, woran das liegt.
Vmtl. liegt das an der Art, wie Du die Elemente einfügst. Schau' Dir mal http://www.xs4all.nl/~ppk/js/options.html an - das funktioniert auch im Netscape 4.
Grüße,
Christian