![]() |
![]() |
![]()
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"> |
|
|
![]() ![]() |
![]() |
Aktualny czas: 22.08.2025 - 15:59 |