![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 544 Pomógł: 5 Dołączył: 18.08.2009 Ostrzeżenie: (0%) ![]() ![]() |
Mam problem ze zdarzeniem i odczytywaniem danych z input[type="file"]. Chcę zrobić tak że po wybraniu pliku, div .upload-button zmienia kolor. Mam taki kod:
Kod var count = document.getElementsByClassName("upload").length; var i=0; for (i; i<count; i++) { document.getElementsByClassName("upload")[i].addEventListener("change", check_upload(i)); } function check_upload(i) { if (document.getElementsByClassName("upload")[i].value!='') { document.getElementsByClassName("upload-button")[i].style.background="green"; console.log("You have selected file to upload"); } else { document.getElementsByClassName("upload-button")[i].style.background="red"; console.log("No file choosen"); } } Kod <div class="upload-button"></div>
<input type="file" name="file" class="upload"> |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 1 268 Pomógł: 254 Dołączył: 11.06.2009 Skąd: Świętochłowice Ostrzeżenie: (0%) ![]() ![]() |
W idealnym świecie NodeList byloby subklasą Array, która zwracałaby niemutowalne tablice (Object.freeze w konstruktorze choćby). No ale nie żyjemy w takim (IMG:style_emoticons/default/sad.gif)
|
|
|
![]() ![]() |
![]() |
Aktualny czas: 14.10.2025 - 21:12 |