Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JS] Dynamicznie wstawienie tr -> td -> div -> input
slepiec68
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 10.12.2010

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


Witam

W JS jestem na poziomie zlobka wiec moje pytanie moze sie niektorym wydac smieszne :/

Tworze dynamicznie tabele: 1 wiersz to 6 kolumn z opisem, 2 wiersz to samo z checkbox-ami, a ponizej wiersz z div w ktorym potrzebuje umiescic input

Mam taki kod:
  1. function dodajtab(id) {
  2.  
  3. var naglowek = new Array("pryw","sluz","PKP","PKS","pasaż","inny");
  4. var input = new Array("prywatny","sluzbowy","pkp","pks","pasazer","inny");
  5.  
  6. var element = document.getElementById("typ_" + id);
  7. var tbl = document.createElement("table");
  8. var tblBody = document.createElement("tbody");
  9. var row = document.createElement("tr");
  10.  
  11. for (var i = 0; i < 6; i++) {
  12. var cell = document.createElement("td");
  13. var cellText = document.createTextNode(naglowek[i]);
  14. cell.appendChild(cellText);
  15. row.appendChild(cell);
  16. }
  17. tblBody.appendChild(row);
  18.  
  19. var row = document.createElement("tr");
  20.  
  21. for (var i = 0; i < 6; i++) {
  22. cell = document.createElement("td");
  23. cell.setAttribute("style", "text-align: center;");
  24. el = document.createElement("input");
  25. el.type = "checkbox";
  26. el.value = "checkbox"
  27. el.name = "wyjazd[" + id + "][" + input[i] + "]";
  28. if(input[i] == "inny") el.setAttribute("onChange", "inny(this); return false;");
  29. cell.appendChild(el);
  30. row.appendChild(cell);
  31. }
  32. tblBody.appendChild(row);
  33.  
  34. var row = document.createElement("tr");
  35.  
  36. cell = document.createElement("td");
  37. cell.setAttribute("colspan", "6");
  38. cell.setAttribute("style", "text-align: center;");
  39.  
  40. el = document.createElement("div");
  41. el.setAttribute("id","wyjazd[" + id + "][inny_block]");
  42. el.setAttribute("style","display: none;");
  43.  
  44. cell.appendChild(el);
  45. row.appendChild(cell);
  46.  
  47. tblBody.appendChild(row);
  48. tbl.appendChild(tblBody);
  49. element.appendChild(tbl);
  50. }


Problem jest taki ze nie moge sobie poradzic z dynamicznym wstawieniem tego ostatniego input do div wyjazd[" + id + "][inny_block] :/

Bede wdzieczny za pomoc.

--
pozdrawiam
Marek
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: 26.08.2025 - 12:34