Dynamische Select-Box

Für Golf hast du jetzt keine Modelle angegeben, also erstmal Platzhalter, die Anzahl kannst du beliebig änern und natürlich auh wie die Download-URL letztendlich gebildet wird.

Hier mein Code:
Code:
<form name="downloader">
		<select name="brand" onchange="if(this.selectedIndex != 0){ this.style.display = 'none'; firstSubmit(this.selectedIndex); }">
			<option> - Marke - </option>
			<option value="Audi">Audi</option>
			<option value="Golf">Golf</option>
			<option value="BMW">BMW</option>
		</select>
		<!-- Audi-Select -->
		<select id="1" onchange="if(this.selectedIndex != 0){ this.style.display = 'none'; document.downloader.button.style.display = ''; }" style="display: none;">
			<option> - Modell - </option>
			<option value="A4">A4</option>
			<option value="A6">A6</option>
			<option value="A8">A8</option>
		</select>
		<!-- Golf-Select -->
		<select id="2" onchange="if(this.selectedIndex != 0){ this.style.display = 'none'; document.downloader.button.style.display = ''; }" style="display: none;">
			<option> - Modell - </option>
			<option value="Golf1">Golf1</option>
			<option value="Golf2">Golf2</option>
			<option value="Golf3">Golf3</option>
		</select>
		<!-- BMW-Select -->
		<select id="3" onchange="if(this.selectedIndex != 0){ this.style.display = 'none'; document.downloader.button.style.display = ''; }" style="display: none;">
			<option> - Modell - </option>
			<option value="x1">x1</option>
			<option value="x6">x6</option>
			<option value="M5">M5</option>
		</select>
		<!-- URL wird zusammengesetzt: <aktuelle url><marke>_<modell> -->
		<input id="button" type="button" value="Download" 
			onClick="location = document.downloader.brand.options[document.downloader.brand.selectedIndex].value + '_' +
				document.getElementById(selectindex).options[document.getElementById(selectindex).selectedIndex].value" 
			style="display: none;" />
	</form>

Edit:
Ich hab jetzt doch mit display gearbeitet und einfach gleich 3 selects im HTML notiert.
 
Hey, danke für deine Bemühungen.

Leider ist jetzt nur noch eine selectbox zu sehen und nach anwählen von Audi, BMW etc. verschwindet die Selectbox und die zweite erscheint nicht ?
 
Sorry, da hab ich den JS-Teil ganz vergessen:
Code:
<script type="text/javascript">
		var selectindex = 0;
		function firstSubmit(index) {
			selectindex = index;
			document.getElementById(index).style.display = '';
		}
	</script>
 

Neue Beiträge

Zurück