![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 19 Pomógł: 0 Dołączył: 7.09.2017 Ostrzeżenie: (0%) ![]() ![]() |
Witam, drukuję sobie listę select z tablicy
Kod <select id="lBetonID"> <option>- wybierz -</option></select> i Kod //Lista dla betonu var zmsel1 = document.getElementById("lBetonID"); var zmopt1 = concrete[0].slice(2); for(var i = 0; i < zmopt1.length; i++) { var opt1 = zmopt1[i]; var el1 = document.createElement("option"); el1.textContent = opt1; el1.value = opt1; zmsel1.appendChild(el1); } Mam problem z ustawieniem wartości wejściowej selected, można gdzieś ją wkomponować? |
|
|
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 6 380 Pomógł: 1116 Dołączył: 30.08.2006 Ostrzeżenie: (0%) ![]() ![]() |
za pętlą
var zmsel1 = document.querySelectorAll('#lBetonID option'); zmsel1[x].selected = true; lub zmsel1.options[x].selected = true gdzie x to numer który chcesz zaznaczyć Ten post edytował viking 20.09.2017, 07:16:44 -------------------- |
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 19 Pomógł: 0 Dołączył: 7.09.2017 Ostrzeżenie: (0%) ![]() ![]() |
Działa jak należy. Dziękuję bardzo!
|
|
|
![]() ![]() |
![]() |
Aktualny czas: 20.08.2025 - 13:02 |