ERLEDIGT
NEIN
NEIN
ANTWORTEN
4
4
ZUGRIFFE
317
317
EMPFEHLEN
-
Hallo!
Wie muss man das folgende Script umschreiben, dass anstatt 0,1 und 2
-> no, yes, auto funktioniert?
HTML-Code:<html> <head> <script> function ShowMenu(num, menu, max) { for(i = 1; i <= num; i++){ //add number onto end of menu var menu2 = menu + i; //change visibility to block, or 'visible' document.getElementById(menu2).style.display = 'block'; } //make a number one more than the number inputed var num2 = num; num2++; //hide it if the viewer selects a number lower //this will hide every number between the selected number and the maximum //ex. if 3 is selected, hide the <div> cells for 4, 5, and 6 //loop until max is reached while(num2 <= max){ var menu3 = menu + num2; //hide document.getElementById(menu3).style.display = 'none'; //add one to loop num2=num2+1; } } </script> </head> <body> <select id='wartung' onChange="javascript: ShowMenu(document.getElementById('wartung').value,'div-wartung', 2);"> <option value='0'>0 <option value='1'>1 <option value='2'>2 </select> <div id='div-wartung1' style="display: none;"> Choose type of flower 1:<br><br> <input type="radio" name="color1" value="red">Red<br> <input type="radio" name="color1" value="white">White<br> <input type="radio" name="color1" value="yellow">Yellow<br> </div> <div id='div-wartung2' style="display: none;"> Choose type of flower 2:<br><br> <input type="radio" name="color2" value="red">Red<br> <input type="radio" name="color2" value="white">White<br> <input type="radio" name="color2" value="yellow">Yellow<br>
Also auf folgendem;
HTML-Code:<select id='wartung' onChange="javascript: ShowMenu(document.getElementById('wartung').value,'div-wartung', 2);"> <option value='0'>0 <option value='1'>1 <option value='2'>2 </select>
soll werden;
HTML-Code:<select id='wartung' onChange="javascript: ShowMenu(document.getElementById('wartung').value,'div-wartung', 2);"> <option value='no'>No <option value='yes'>Yes <option value='auto'>Auto </select>
Und die funktionsweise soll weiterhin bestehen bleiben
Geändert von Lektor21 (10.02.08 um 23:25 Uhr)
-
Hab nun ein Script gefunden, was funktioniert!
Nur noch nen kleines Problem; wenn ich in der Liste den ersten auswähle blendet er nicht alle aus, wie ich aber eigentlich definiert habe!?HTML-Code:function setVisibility() { var val=document.wartung.wartung_updated.selectedIndex; if(val){ if(val == 0){ option1_part1.style.display = 'none'; option1_part2.style.display = 'none'; option2_part1.style.display = 'none'; option2_part2.style.display = 'none'; } if(val == 1){ option1_part1.style.display = 'none'; option1_part2.style.display = 'none'; option2_part1.style.display = 'block'; option2_part2.style.display = 'block'; } if(val == 2){ option1_part1.style.display = 'block'; option1_part2.style.display = 'block'; option2_part1.style.display = 'block'; option2_part2.style.display = 'block'; } } }
-
if(val)...prüft, ob val true istCode :
1 2 3
if(val){ if(val == 0){
wenn val allerdings 0 ist(falls erste Option gewählt wurde)...dann kommst du überhaupt nicht in den Abzweig, weil val dann false ist.(bei einer Prüfung auf einen booleschen Wert wird 0 als false gewertet)
-
Ok hab entfernt! Dankeschön, jetzt funktioniert es!
Also ich hole den Inhalt vorher aus einer Datenbank und je nachdem checke ich das Selectfeld, also entweder no, yes oder auto.
Ist es eigentlich auch möglich, dass wenn man auf die Seite kommt, dass automatisch eben die Felder ausgeblendet werden, die nicht hingehören?
Weil wenn ich nichts anklicke sieht man ja alle DIVS!
-
Klar, du kannst bspw. beim onLoad der Seite die Funktion aufrufen:
Code :1
window.onload=setVisibility;
Ähnliche Themen
-
Kleines Problem!
Von SixxKiller im Forum HTML & XHTMLAntworten: 3Letzter Beitrag: 12.12.06, 20:22 -
Kleines SQL Problem
Von xloouch im Forum JavaAntworten: 2Letzter Beitrag: 05.07.06, 21:45 -
kleines problem
Von saua im Forum PHPAntworten: 3Letzter Beitrag: 02.05.05, 13:38 -
kleines CSS Problem!
Von seril im Forum CSSAntworten: 10Letzter Beitrag: 02.12.04, 00:36 -
Hab ein kleines Problem mit cgi .....
Von Jimbo2001 im Forum CGI, Perl, Python, Ruby, Power ShellAntworten: 20Letzter Beitrag: 16.08.01, 12:06





Zitieren
Login





