![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 4 340 Pomógł: 542 Dołączył: 15.01.2006 Skąd: Olsztyn/Warszawa Ostrzeżenie: (0%) ![]() ![]() |
Witam chcialbym utworzyc nowy obiekt typu <select> w oparciu o juz istniejacy, niby dosyc proste ale jednak.
kod
problem wyglada nastepujaco. Kod Error: oList.options[i] has no properties Source File: file:///C:/AppServ/www/javascript/selectOptions.html Line: 13 ale jak odkomentuje alerta to elegancko wywali on wszystkie wartosci tej listy |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 158 Pomógł: 43 Dołączył: 9.11.2007 Ostrzeżenie: (0%) ![]() ![]() |
Powinno działać:
Kod function showOptions(){
var select = document.createElement('select'); var oList = document.getElementById('abc'); var oDiv = document.getElementById('oDiv'); for(var i=0,n=oList.length; i<n; i++){ option = document.createElement('option'); option.setAttribute('value',oList.options[i].value); option.appendChild(document.createTextNode(oList.options[i].text)); select.appendChild(option); } oDiv.appendChild(select); } |
|
|
![]() ![]() |
![]() |
Aktualny czas: 3.10.2025 - 13:40 |