Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [js]Dodawanie pola input wraz z opisem
qrcze_pieczone
post
Post #1





Grupa: Zarejestrowani
Postów: 59
Pomógł: 2
Dołączył: 13.04.2007

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


Witam
ma taki kod w js (zapożyczony z http://ferrante.pl )
  1. function Laduj()
  2. {
  3. var ilosc = document.forms['add_input'].elements.length;
  4. for (var i = 0; i < ilosc; i++ )
  5. {
  6. document.forms['add_input'].elements[i].onkeyup = SumujInput;
  7. }
  8. document.getElementById('add_input').onclick = DodajInput;
  9. }
  10. function DodajInput()
  11. {
  12. var element = document.createElement('input');
  13. element.setAttribute('type', 'text');
  14.  
  15. var liczba = 0;
  16. var ilosc = document.forms['add_input'].elements.length;
  17. for (var i = 0; i < ilosc; i++ )
  18. {
  19. if (document.forms['add_input'].elements[i].type == 'text')
  20. {
  21. liczba += 1;
  22. }
  23.  
  24. }
  25. element.setAttribute('name', 'file-'+(liczba+1));
  26. element.style.display = "block";
  27. element.style.margin= "2px";
  28. element.label.setAttribute('id', 'file-'+(liczba+1));
  29. document.forms['add_input'].appendChild(element);
  30. document.forms['add_input'].elements['file-'+(liczba+1)].onkeyup = SumujInput;
  31. }

który daje możliwość dodawania kolejnego pola input czyli:

  1. <form><input type="text" name="file-1" value="0"/><br />
  2. <input type="text" name="file-2" value="0"/>
  3. </form>


i moje pytanie jest takie co zrobić aby oprócz pola input uzyskać ta metodą opis z każdego inputa czyli np

  1. <label for="file-1">Rata 1<input type="text" name="file-1" value="0"/></label>
  2. <label for="file-2">Rata 2 <input type="text" name="file-2" value="0"/></label>
  3. </form>


czyli czy jest w ogóle możliwość aby w formularzu umieścić Element <label> wraz z opisem

pozdrawiam
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: 23.08.2025 - 08:58