Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][JavaScript]Zawartość pola input
brymen2
post
Post #1





Grupa: Zarejestrowani
Postów: 25
Pomógł: 0
Dołączył: 1.12.2011

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


Witam, poniższy skrypt zlicza ilość zaznaczonych checkboxów, jak uzyskać efekt w którym wyświetlana byłaby zawartość input: id,value,class/id,value,class/id,value,class... zaznaczonych checkboxów

  1. <form method="post" name=test>
  2. <script language="JavaScript1.3">
  3. function licz(form) {
  4. var zaznaczone = 0;
  5. var max = form.ckbox.length;
  6. for (var idx = 0; idx < max; idx++) {
  7. if (eval("document.test.ckbox[" + idx + "].checked") == true) {
  8.  
  9. zaznaczone += 1;
  10.  
  11. }
  12.  
  13. }
  14. document.getElementById("check").value=zaznaczone + "/" + max;
  15. }
  16. </script >
  17.  
  18. <input type="checkbox" id="ckbox" class="wiersz1" value="1" onclick="licz(this.form)" /> checkbox 1<BR />
  19. <input type="checkbox" id="ckbox" class="wiersz2" value="2" onclick="licz(this.form)" /> checkbox 2<BR />
  20. <input type="checkbox" id="ckbox" class="wiersz3" value="3" onclick="licz(this.form)" /> checkbox 3<BR />
  21. <input type="checkbox" id="ckbox" class="wiersz4" value="4" onclick="licz(this.form)" /> checkbox 4<BR />
  22. <input type="checkbox" id="ckbox" class="wiersz5" value="5" onclick="licz(this.form)" /> checkbox 5<BR />
  23. <input type="checkbox" id="ckbox" class="wiersz6" value="6" onclick="licz(this.form)" /> checkbox 6<BR />
  24.  
  25. <input id="check" type="text">
  26. </form >


Ten post edytował brymen2 3.12.2011, 09:59:39
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: 24.08.2025 - 12:00