| Vorheriges Thema anzeigen :: Nächstes Thema anzeigen |
| Autor |
Nachricht |
Phil1710 Mitglied
|
Doppelmenue bei ID in <form> geht nicht |
|
|
Hallo,
ich habe ein in einen Javascript hinterlegtes Doppelmenue, welches in meinem html form feld jedoch nicht funktioniert. Irgendwie verträgt es sich nicht mit der ID, welche ich dieser form zugeteilt habe.
Kann mir da jemand helfen? ich komme absolut nicht weiter.
anbei sind die codes:
In der HTML Datei
| Code: | <form id="search-form" name="doppelmenue" action="">
<script type="text/javascript" src="script.js"></script>
|
usw...
in der Javascript Datei
| Code: | document.write(' <form name="doppelmenue" action=""> ');
document.write(' <select name="auswahlliste" size="1" onChange="redirect(this.options.selectedIndex)"> ');
document.write(' <option>Deutschland / Germany</option> ');
document.write(' <option>Oesterreich / Austria</option> ');
document.write(' <option>Schweiz / Swizzerland</option> ');
document.write(' </select> <br>');
document.write(' <label class="" for="destination">Stadt / City</label><br/>');
document.write(' <select name="auswahlliste2" size="1"> ');
document.write(' <option value="../databases/stuttgartdata.htm">Bitte auswaehlen:</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Berlin</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Bremen</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Dortmund</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Dresden</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Duesseldorf</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Erfurt</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Frankfurt am Main</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Hamburg</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Hannover</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Koeln</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Kreis Taunus</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Leipzig</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Mainz / Wiesbaden</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Mannheim</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Muenchen</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Nuernberg</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Stuttgart</option> ');
document.write(' </select> ');
document.write(' </form> ');
var temp = document.doppelmenue.auswahlliste2;
function redirect(x) {
for (var zaehler = temp.options.length-1; zaehler > 0; zaehler--) {
temp.options[zaehler] = null;
}
for (var zaehler = 0; zaehler < auswahl[x].length; zaehler++) {
temp.options[zaehler] = new Option(auswahl[x][zaehler].text,auswahl[x][zaehler].value);
}
temp.options[0].selected = true;
}
function auswaehlen() {
location.href = temp.options[temp.selectedIndex].value;
}
// Doppelte Menü-Auswahlliste
var groups = document.doppelmenue.auswahlliste.options.length;
var auswahl = new Array(groups);
for (var zaehler = 0; zaehler < groups; zaehler++) {
auswahl[zaehler] = new Array();
}
auswahl[0][0] = new Option("Berlin", "../databases/loadingdata/loadingberlin.htm");
auswahl[0][1] = new Option("Bremen", "../databases/hamburgdata.htm");
auswahl[0][2] = new Option("Dortmund", "../databases/hannoverdata.htm");
auswahl[0][3] = new Option("Dresden", "../databases/bremendata.htm");
auswahl[0][4] = new Option("Duesseldorf", "../databases/dortmunddata.htm");
auswahl[0][5] = new Option("Erfurt", "../databases/duesseldorfdata.htm");
auswahl[0][6] = new Option("Frankfurt am Main", "../databases/koelndata.htm");
auswahl[0][7] = new Option("Hamburg", "../databases/leipzigdata.htm");
auswahl[0][8] = new Option("Hannover", "../databases/dresdendata.htm");
auswahl[0][9] = new Option("Koeln", "../databases/erfurtdata.htm");
auswahl[0][10] = new Option("Kreis Taunus", "../databases/taunusdata.htm");
auswahl[0][11] = new Option("Leipzig", "../databases/loadingdata/loadingmzwi.htm");
auswahl[0][12] = new Option("Mainz / Wiesbaden", "../databases/frankfurtdata.htm");
auswahl[0][13] = new Option("Mannheim", "../databases/nuernbergdata.htm");
auswahl[0][14] = new Option("Muenchen", "../databases/mannheimdata.htm");
auswahl[0][15] = new Option("Nuernberg", "../databases/stuttgartdata.htm");
auswahl[0][16] = new Option("Stuttgart", "../databases/loadingdata/loadingmuenchen.htm");
auswahl[1][0] = new Option("Linz", "../databases/linzdata.htm");
auswahl[1][1] = new Option("St.Poelten", "../databases/poeltendata.htm");
auswahl[1][2] = new Option("Graz", "../databases/grazdata.htm");
auswahl[1][3] = new Option("Innsbruch", "../databases/innsbruckdata.htm");
auswahl[1][4] = new Option("Salzburg", "../databases/salzburgdata.htm");
auswahl[1][5] = new Option("Kitzbuehel", "../databases/kitzbueheldata.htm");
auswahl[1][6] = new Option("Klagenfurt", "../databases/klagenfurtdata.htm");
auswahl[1][7] = new Option("Wien", "../databases/loadingdata/loadingwien.htm");
auswahl[2][0] = new Option("Zuerich", "fehler.html");
auswahl[2][1] = new Option("Bern", "fehler.html");
auswahl[2][2] = new Option("Basel", "fehler.html");
auswahl[2][3] = new Option("Genf", "fehler.html");
auswahl[2][4] = new Option("Luzern", "fehler.html");
auswahl[2][5] = new Option("Lausanne", "fehler.html");
auswahl[2][6] = new Option("Montreux", "fehler.html"); |
|
|
|
|
| 04 Feb 2012 13:17 |
|
  |
Werner Homepage-Total.de Moderator

|
Re: Doppelmenue bei ID in <form> geht nicht |
|
|
Du hast zweimal den Form-Tag dort stehen!
| Phil1710 hat Folgendes geschrieben: |
| Code: | <form id="search-form" name="doppelmenue" action="">
<script type="text/javascript" src="script.js"></script>
|
usw...
in der Javascript Datei
| Code: | document.write(' <form name="doppelmenue" action=""> ');
|
|
|
|
|
|
| 04 Feb 2012 15:14 |
|
 |
Phil1710 Mitglied
|
 |
|
|
Hallo Werner,
habe nun das form aus der javascript datei entfernt.
Das Doppelmenu wird angezeigt, jedoch wenn ich zb Österreich anklicke, werden mir nicht die Städte, welche ich für Österreich definiert habe im 2. Menü angezeigt |
|
|
|
| 04 Feb 2012 15:23 |
|
 |
Phil1710 Mitglied
|
 |
|
|
..Es funktioniert lustigerweise nur, wenn ich die "id" der form in der html datei entferne.
jedoch habe ich dann wiederrum ein unschönes doppelmenu, da ich mit der ID das doppelmenu etwas "gestylt" habe |
|
|
|
| 04 Feb 2012 15:36 |
|
 |
Werner Homepage-Total.de Moderator

|
 |
|
|
Komisch, bei mir funktioniert es!
| Code: | <form id="search-form" name="doppelmenue" action="">
<script type="text/javascript">
document.write(' <select name="auswahlliste" size="1" onChange="redirect(this.options.selectedIndex)"> ');
document.write(' <option>Deutschland / Germany</option> ');
document.write(' <option>Oesterreich / Austria</option> ');
document.write(' <option>Schweiz / Swizzerland</option> ');
document.write(' </select> <br>');
document.write(' <label class="" for="destination">Stadt / City</label><br/>');
document.write(' <select name="auswahlliste2" size="1"> ');
document.write(' <option value="../databases/stuttgartdata.htm">Bitte auswaehlen:</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Berlin</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Bremen</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Dortmund</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Dresden</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Duesseldorf</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Erfurt</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Frankfurt am Main</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Hamburg</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Hannover</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Koeln</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Kreis Taunus</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Leipzig</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Mainz / Wiesbaden</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Mannheim</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Muenchen</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Nuernberg</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Stuttgart</option> ');
document.write(' </select> ');
var temp = document.doppelmenue.auswahlliste2;
function redirect(x) {
for (var zaehler = temp.options.length-1; zaehler > 0; zaehler--) {
temp.options[zaehler] = null;
}
for (var zaehler = 0; zaehler < auswahl[x].length; zaehler++) {
temp.options[zaehler] = new Option(auswahl[x][zaehler].text,auswahl[x][zaehler].value);
}
temp.options[0].selected = true;
}
function auswaehlen() {
location.href = temp.options[temp.selectedIndex].value;
}
// Doppelte Menü-Auswahlliste
var groups = document.doppelmenue.auswahlliste.options.length;
var auswahl = new Array(groups);
for (var zaehler = 0; zaehler < groups; zaehler++) {
auswahl[zaehler] = new Array();
}
auswahl[0][0] = new Option("Berlin", "../databases/loadingdata/loadingberlin.htm");
auswahl[0][1] = new Option("Bremen", "../databases/hamburgdata.htm");
auswahl[0][2] = new Option("Dortmund", "../databases/hannoverdata.htm");
auswahl[0][3] = new Option("Dresden", "../databases/bremendata.htm");
auswahl[0][4] = new Option("Duesseldorf", "../databases/dortmunddata.htm");
auswahl[0][5] = new Option("Erfurt", "../databases/duesseldorfdata.htm");
auswahl[0][6] = new Option("Frankfurt am Main", "../databases/koelndata.htm");
auswahl[0][7] = new Option("Hamburg", "../databases/leipzigdata.htm");
auswahl[0][8] = new Option("Hannover", "../databases/dresdendata.htm");
auswahl[0][9] = new Option("Koeln", "../databases/erfurtdata.htm");
auswahl[0][10] = new Option("Kreis Taunus", "../databases/taunusdata.htm");
auswahl[0][11] = new Option("Leipzig", "../databases/loadingdata/loadingmzwi.htm");
auswahl[0][12] = new Option("Mainz / Wiesbaden", "../databases/frankfurtdata.htm");
auswahl[0][13] = new Option("Mannheim", "../databases/nuernbergdata.htm");
auswahl[0][14] = new Option("Muenchen", "../databases/mannheimdata.htm");
auswahl[0][15] = new Option("Nuernberg", "../databases/stuttgartdata.htm");
auswahl[0][16] = new Option("Stuttgart", "../databases/loadingdata/loadingmuenchen.htm");
auswahl[1][0] = new Option("Linz", "../databases/linzdata.htm");
auswahl[1][1] = new Option("St.Poelten", "../databases/poeltendata.htm");
auswahl[1][2] = new Option("Graz", "../databases/grazdata.htm");
auswahl[1][3] = new Option("Innsbruch", "../databases/innsbruckdata.htm");
auswahl[1][4] = new Option("Salzburg", "../databases/salzburgdata.htm");
auswahl[1][5] = new Option("Kitzbuehel", "../databases/kitzbueheldata.htm");
auswahl[1][6] = new Option("Klagenfurt", "../databases/klagenfurtdata.htm");
auswahl[1][7] = new Option("Wien", "../databases/loadingdata/loadingwien.htm");
auswahl[2][0] = new Option("Zuerich", "fehler.html");
auswahl[2][1] = new Option("Bern", "fehler.html");
auswahl[2][2] = new Option("Basel", "fehler.html");
auswahl[2][3] = new Option("Genf", "fehler.html");
auswahl[2][4] = new Option("Luzern", "fehler.html");
auswahl[2][5] = new Option("Lausanne", "fehler.html");
auswahl[2][6] = new Option("Montreux", "fehler.html");
</script>
</form> |
|
|
|
|
| 04 Feb 2012 15:47 |
|
 |
Phil1710 Mitglied
|
 |
|
|
was gibst du in der html datei ein?
per Such button soll das menu dann ausgewählt werden |
|
|
|
| 04 Feb 2012 15:52 |
|
 |
Werner Homepage-Total.de Moderator

|
 |
|
|
Was heißt: | Zitat: | | per Such button soll das menu dann ausgewählt werden |
Nach dem auswählen soll man zur ausgewählten Seite gelangen Oder?
Hier ein Beispiel:
| Code: |
<form id="search-form" name="doppelmenue" action="">
<script type="text/javascript">
document.write(' <select name="auswahlliste" size="1" onChange="redirect(this.options.selectedIndex)"> ');
document.write(' <option>Deutschland / Germany</option> ');
document.write(' <option>Oesterreich / Austria</option> ');
document.write(' <option>Schweiz / Swizzerland</option> ');
document.write(' </select> <br>');
document.write(' <label class="" for="destination">Stadt / City</label><br/>');
document.write(' <select name="auswahlliste2" size="1"> ');
document.write(' <option value="../databases/stuttgartdata.htm">Bitte auswaehlen:</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Berlin</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Bremen</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Dortmund</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Dresden</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Duesseldorf</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Erfurt</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Frankfurt am Main</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Hamburg</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Hannover</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Koeln</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Kreis Taunus</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Leipzig</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Mainz / Wiesbaden</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Mannheim</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Muenchen</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Nuernberg</option> ');
document.write(' <option value="../databases/stuttgartdata.htm">Stuttgart</option> ');
document.write(' </select> ');
var temp = document.doppelmenue.auswahlliste2;
function redirect(x) {
for (var zaehler = temp.options.length-1; zaehler > 0; zaehler--) {
temp.options[zaehler] = null;
}
for (var zaehler = 0; zaehler < auswahl[x].length; zaehler++) {
temp.options[zaehler] = new Option(auswahl[x][zaehler].text,auswahl[x][zaehler].value);
}
temp.options[0].selected = true;
}
function auswaehlen() {
location.href = temp.options[temp.selectedIndex].value;
}
// Doppelte Menü-Auswahlliste
var groups = document.doppelmenue.auswahlliste.options.length;
var auswahl = new Array(groups);
for (var zaehler = 0; zaehler < groups; zaehler++) {
auswahl[zaehler] = new Array();
}
auswahl[0][0] = new Option("Berlin", "../databases/loadingdata/loadingberlin.htm");
auswahl[0][1] = new Option("Bremen", "../databases/hamburgdata.htm");
auswahl[0][2] = new Option("Dortmund", "../databases/hannoverdata.htm");
auswahl[0][3] = new Option("Dresden", "../databases/bremendata.htm");
auswahl[0][4] = new Option("Duesseldorf", "../databases/dortmunddata.htm");
auswahl[0][5] = new Option("Erfurt", "../databases/duesseldorfdata.htm");
auswahl[0][6] = new Option("Frankfurt am Main", "../databases/koelndata.htm");
auswahl[0][7] = new Option("Hamburg", "../databases/leipzigdata.htm");
auswahl[0][8] = new Option("Hannover", "../databases/dresdendata.htm");
auswahl[0][9] = new Option("Koeln", "../databases/erfurtdata.htm");
auswahl[0][10] = new Option("Kreis Taunus", "../databases/taunusdata.htm");
auswahl[0][11] = new Option("Leipzig", "../databases/loadingdata/loadingmzwi.htm");
auswahl[0][12] = new Option("Mainz / Wiesbaden", "../databases/frankfurtdata.htm");
auswahl[0][13] = new Option("Mannheim", "../databases/nuernbergdata.htm");
auswahl[0][14] = new Option("Muenchen", "../databases/mannheimdata.htm");
auswahl[0][15] = new Option("Nuernberg", "../databases/stuttgartdata.htm");
auswahl[0][16] = new Option("Stuttgart", "../databases/loadingdata/loadingmuenchen.htm");
auswahl[1][0] = new Option("Linz", "../databases/linzdata.htm");
auswahl[1][1] = new Option("St.Poelten", "../databases/poeltendata.htm");
auswahl[1][2] = new Option("Graz", "../databases/grazdata.htm");
auswahl[1][3] = new Option("Innsbruch", "../databases/innsbruckdata.htm");
auswahl[1][4] = new Option("Salzburg", "../databases/salzburgdata.htm");
auswahl[1][5] = new Option("Kitzbuehel", "../databases/kitzbueheldata.htm");
auswahl[1][6] = new Option("Klagenfurt", "../databases/klagenfurtdata.htm");
auswahl[1][7] = new Option("Wien", "../databases/loadingdata/loadingwien.htm");
auswahl[2][0] = new Option("Zuerich", "fehler.html");
auswahl[2][1] = new Option("Bern", "fehler.html");
auswahl[2][2] = new Option("Basel", "fehler.html");
auswahl[2][3] = new Option("Genf", "fehler.html");
auswahl[2][4] = new Option("Luzern", "fehler.html");
auswahl[2][5] = new Option("Lausanne", "fehler.html");
auswahl[2][6] = new Option("Montreux", "fehler.html");
function Go() {
location.href= document.doppelmenue.auswahlliste2.options[document.doppelmenue.auswahlliste2.selectedIndex].value;
}
</script>
<input type="button" value="Button" onClick="Go()">
</form>
|
|
|
|
|
| 04 Feb 2012 16:06 |
|
 |
Phil1710 Mitglied
|
 |
|
|
also da wird bei mir garnichts angezeigt kann ich dir meine beiden dateien mal zukommen lassen per mail?
das ist alles sehr seltsam |
|
|
|
| 04 Feb 2012 16:22 |
|
 |
Werner Homepage-Total.de Moderator

|
 |
|
|
Die Dateien kannst du mir senden, ich werde das
Problem dann genauer anschauen. |
|
|
|
| 06 Feb 2012 20:15 |
|
 |
Phil1710 Mitglied
|
 |
|
|
Hallo Werner,
würde es dir gerne zukommen lassen, jedoch kann ich dir hier leider keine PN senden "Nachrichten wurden an diesem Board deaktiviert" desweiteren finde ich auch eine eMail Adresse von dir.
Wie kann ich dir meine gezippten Dateien zukommen lassen?
Beste Grüße
Philip |
|
|
|
| 07 Feb 2012 23:57 |
|
 |
|