Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z onchange w input file w ie
marrrecki
post
Post #1





Grupa: Zarejestrowani
Postów: 110
Pomógł: 0
Dołączył: 19.07.2006
Skąd: Lublin

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


Witam. MAm problem. zrobiłem sobie funkcję, która po wybraniu jednego pliku poprzez input file tworzy mi w divie kolejny input. wszystko działa pod operą i ff, ale pod ie niestety nie chce.
Oto ta funkcja:
  1. function DodajElement()
  2. {
  3. var element = document.createElement('input');
  4. element.setAttribute('type', 'file');
  5. element.setAttribute('onchange', 'javascript:DodajElement();');
  6.  
  7. var liczba = 0;
  8. var ilosc = document.forms['newsy_edit'].elements.length;
  9. for (var i = 0; i < ilosc; i++ )
  10. {
  11. if (document.forms['newsy_edit'].elements[i].type == 'file')
  12. {
  13. liczba += 1;
  14. }
  15. }
  16.  
  17. element.setAttribute('name', 'file-'+(liczba+1));
  18.  
  19. element.style.display = "block";
  20. element.style.margin= "2px";
  21.  
  22. var div = document.getElementById('dodatkowe');
  23. div.appendChild(element);
  24.  
  25. //alert(element.onchange);
  26.  
  27. document.forms["newsy_edit"].dodatkowe_ilosc.value = liczba;
  28. }


Czy ktoś może mi powiedzieć o co biega?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
gekon
post
Post #2





Grupa: Zarejestrowani
Postów: 614
Pomógł: 7
Dołączył: 10.11.2003
Skąd: Rzeszów/Kraków

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


@marrrecki:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  3. <title>{$lang_TITLE}</title>
  4. <script type="text/javascript">
  5. function DodajElement(){
  6. var element = document.createElement('input');
  7. element.setAttribute('type', 'file');
  8.  
  9. var liczba = 0;
  10. var ilosc = document.forms['newsy_edit'].elements.length;
  11. for (var i = 0; i < ilosc; i++ ) {
  12. if (document.forms['newsy_edit'].elements[i].type == 'file'){
  13. liczba += 1;
  14. }
  15. }
  16.  
  17. element.setAttribute('name', 'file-'+(liczba+1));
  18.  
  19. element.style.display = "block";
  20. element.style.margin= "2px";
  21.  
  22. var div = document.getElementById('dodatkowe');
  23. var lastInput = div.appendChild(element);
  24.  
  25. document.forms["newsy_edit"].dodatkowe_ilosc.value = liczba;
  26.  
  27. lastInput.onchange = function(){
  28. DodajElement();
  29. }
  30. }
  31. window.onload = function (){
  32. DodajElement();
  33. }
  34. </head>
  35. <form id="newsy_edit" action="#" method="post">
  36. <input type="text" name="dodatkowe_ilosc" />
  37. <div id="dodatkowe">
  38.  
  39. </div>
  40. </form>
  41. </body>
  42. </html>


@John: http://www.w3.org/TR/html401/interact/scripts.html#events - widzisz tu gdzie onLoad? Bo ja tylko onload itd.

Ten post edytował gekon 21.01.2008, 17:59:48
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: 3.10.2025 - 15:15