Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z innerHTML
diamondking
post
Post #1





Grupa: Zarejestrowani
Postów: 100
Pomógł: 0
Dołączył: 7.02.2014

Ostrzeżenie: (0%)
-----


Cześć.
Mam dwa osobne ale identyczne formularze, w każdym jest pole file z innym id.

W JS mam skrypt by podczas zmiany tego pola usuwało zawartość z diva.

  1. $('#avatarimg').on('change', function() {
  2. document.getElementsByClassName('noti')[0].innerHTML = '';
  3. });


tak samo w drugim

  1. $('#bgimg').on('change', function() {
  2. document.getElementsByClassName('noti')[0].innerHTML = '';
  3. });


W pierwszym formularza działa poprawnie, w drugim już nie. Pomożecie?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
diamondking
post
Post #2





Grupa: Zarejestrowani
Postów: 100
Pomógł: 0
Dołączył: 7.02.2014

Ostrzeżenie: (0%)
-----


Niestety nie działa, widocznie gdzie indziej w kodzie mam jakiś błąd (IMG:style_emoticons/default/smile.gif)
Tworzę to na przykładach z sieci bo nie znam się na JS ;/

  1. $('#avatarimg').on('change', function() {
  2. var buttonblock = document.getElementById("avatarsend");
  3. if(this.files[0].size > 2097152){
  4. buttonblock.classList.add("disabled");
  5. document.getElementsByClassName('txtavatar')[0].innerHTML = '<span class="error">Maksymalny rozmiar pliku 2Mb</span>';
  6. }else{
  7. buttonblock.classList.remove("disabled");
  8. document.getElementsByClassName('txtavatar')[0].innerHTML = '';
  9. }
  10. document.getElementsByClassName('noti')[1].innerHTML = '';
  11. });


pod spodem mam taki kod do drugiego pola

  1. $('#bgimg').on('change', function() {
  2. var buttonblock = document.getElementById("bgsend");
  3. if(this.files[0].size > 2097152){
  4. buttonblock.classList.add("disabled");
  5. document.getElementsByClassName('txtbg')[0].innerHTML = '<span class="error">Maksymalny rozmiar pliku 2Mb</span>';
  6. }else{
  7. buttonblock.classList.remove("disabled");
  8. document.getElementsByClassName('txtbg')[0].innerHTML = '';
  9. }
  10. document.getElementsByClassName('noti')[1].innerHTML = '';
  11. });
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 12.10.2025 - 12:18