Witam,
Napisałem kod który dynamicznie wyświetla informacje po zmianie wyboru.
Wygląda on mniej więcej tak.
<script>
<!--
//mozliwosci w option
var oznaczenia
= new Array('18NV','18SV','18SEH','E18 NVR','20SE','C20NE','C20NEF','C20NEJ','C26NE','30NE','C30LE','C30NE','C30SE','C30SEJ','C30XEI','C36GET','C40SE','23YD','23YDT','23DTR'); var lata
= new Array('1986-1987','1986-1987','1986-1992','1987-1990','1986-1987','1986-1993','b.d.','1990-1993','1990-1993','1986-1990','1986-1988','1990-1993','1989-1993','1986-1993','b.d.','b.d.','b.d.','1986-1993','1986-1988','1988-1993'); var pojemnosc
= new Array('1796','1796','1796','1796','1998','1998','1998','1998','2594','2969','2969','2969','2969','2969','3637','3983','2260','2260','2260'); var cylindrow
= new Array('4','4','4','4','4','4','4','4','6','6','6','6','6','6','6','6','6','4','4','4'); var zawory
= new Array('8','8','8','8','8','8','8','8','12','12','12','12','24','24','24','24','24','8','8','8'); var zasilanie
= new Array('gaźnik','gaźnik','Bosch L3 Jetronic','Pierburg 2EE','b.d.','Bosch Motronic ML4.1 oraz 1.5','b.d.','b.d.','Bosch Motronic 1.5','Bosch LE Jetronic','b.d.','Bosch Motronic ML4 oraz 1.5','Bosch Motronic 1.5','b.d.','b.d.','b.d.','b.d.','Bosch VE4','Bosch VE4','Bosch VE4'); var rozrzad
= new Array('OHC','OHC','OHC','OHC','OHC','OHC','OHC','OHC','CIH','CIH','CIH','CIH','DOHC','DOHC','DOHC','DOHC','DOHC','OHC','OHC','OHC'); var sprezanie
= new Array('9.2:1','10.0:1','10.0:1','9.2:1','10.0:1','9.2:1','9.2:1','9.2:1','9.2:1','9.4:1','8.6:1','9.2:1','10.0:1','10.0:1','10.5:1','8.2:1','10.0:1','23:01','23:01','23:01'); var km
= new Array('82 (60) @ 5400','90 (66) @ 5200','116 (85) @ 5600','88 (65) @ 5200','122 (90) @ 5400','116 (85) @ 5400','101 (74) @ 5200','99 (73) @ 5200','150 (110) @ 5600','177 (130) @ 5800','156 (115) @ 5400','177 (130) @ 5800','204 (150) @ 6000','200 (147) @ 6000','230 (169) @ 6700','377 (277) @ 5200','272 (200) @ 5800','73 (54) @ 4400','90 (66) @ 4200','101 (74) @ 4200'); var nm
= new Array('135 @ 3000','148 @ 3400','160 @ 4600','143 @ 3200','175 @ 2600','170 @ 2600','158 @ 2600','170 @ 2600','220 @ 3600','240 @ 4400','230 @ 3800','240 @ 4200','270 @ 3600','265 @ 3600','280 @ 3500','557 @ 4200','395 @ 3300','138 @ 2400','190 @ 2200','218 @ 2000'); var srednica
= new Array('84.4 x 79.5','84.4 x 79.5','84.4 x 79.5','84.4 x 79.5','86.0 x 86.0','86.0 x 86.0','86.0 x 86.0','86.0 x 86.0','88.8 x 69.8','95.0 x 69.8','95.0 x 69.8','95.0 x 69.8','95.0 x 69.8','95.0 x 69.8','95.0 x 69.8','95.3 x 85','98.0 x 88','92 x 85','92 x 85','92 x 85');
//-->
</script>
<select name="silnik" size="1" onChange="document.getElementById('oznaczenia').innerHTML=oznaczenia[this.getElementsByTagName('option')[this.selectedIndex].value];
document.getElementById('lata').innerHTML=lata[this.getElementsByTagName('option')[this.selectedIndex].value];
document.getElementById('pojemnosc').innerHTML=pojemnosc[this.getElementsByTagName('option')[this.selectedIndex].value];
document.getElementById('cylindrow').innerHTML=cylindrow[this.getElementsByTagName('option')[this.selectedIndex].value];
document.getElementById('zawory').innerHTML=zawory[this.getElementsByTagName('option')[this.selectedIndex].value];
document.getElementById('zasilanie').innerHTML=zasilanie[this.getElementsByTagName('option')[this.selectedIndex].value];
document.getElementById('rozrzad').innerHTML=rozrzad[this.getElementsByTagName('option')[this.selectedIndex].value];
document.getElementById('sprezanie').innerHTML=sprezanie[this.getElementsByTagName('option')[this.selectedIndex].value];
document.getElementById('km').innerHTML=km[this.getElementsByTagName('option')[this.selectedIndex].value];
document.getElementById('nm').innerHTML=nm[this.getElementsByTagName('option')[this.selectedIndex].value];
document.getElementById('srednica').innerHTML=srednica[this.getElementsByTagName('option')[this.selectedIndex].value];">
<option selected>--WYBIERZ MODEL SILNIKA--</option>
<option value="0">18NV</option>
<option value="1">18SV</option>
<option value="2">18SEH</option>
<option value="3">E18 NVR</option>
<option value="4">20SE</option>
<option value="5">C20NE</option>
<option value="6">C20NEF</option>
<option value="7">C20NEJ</option>
<option value="8">C26NE</option>
<option value="9">30NE</option>
<option value="10">C30LE</option>
<option value="11">C30NE</option>
<option value="12">C30SE</option>
<option value="13">C30SEJ</option>
<option value="14">C30XEI</option>
<option value="15">C36GET</option>
<option value="16">C40SE</option>
<option value="17">23YD DIESEL</option>
<option value="18">23YDT DIESEL</option>
<option value="19">23DTR DIESEL</option>
</select></br>
Oznaczenie: <b id="oznaczenia"></b></br>
Lata produkcji: <b id="lata"></b></br>
Pojemność: <b id="pojemnosc"></b></br>
Ilość cylindrów: <b id="cylindrow"></b></br>
ILość zaworów: <b id="zawory"></b></br>
Zasilanie: <b id="zasilanie"></b></br>
Rozrząd: <b id="rozrzad"></b></br>
Stopień sprężania: <b id="sprezanie"></b></br>
Maks KM (kW)/RPM: <b id="km"></b></br>
Maks Nm/RPM: <b id="nm"></b></br>
Średnica × skok tłoka: <b id="srednica"></b></br>
Chciałbym jednak go zapisać do pliku *.js a na stronie wyświetlić tylko informację w postaci <script>nazwafunkcji()</script>. I w tym miejscu wyświetla się lista rozwijana i pozycje pod nią czyli "Oznaczenie: ....".
W JS jestem bardzo cienki. Pomoże ktoś?