Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> pętla po checkboxach // rozwiązany
john_doe
post
Post #1





Grupa: Zarejestrowani
Postów: 873
Pomógł: 25
Dołączył: 24.07.2005

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


Mam taki form
  1. <form name="myForm" action="od.php" method="post" >
  2.  
  3. <input type="checkbox" id="id1" name="czek[]" value="1" />
  4. <input type="checkbox" id="id2" name="czek[]" value="2" />
  5. <input type="checkbox" id="id3" name="czek[]" value="3" />
  6. <input type="checkbox" id="id4" name="czek[]" value="4" />
  7. <input type="checkbox" id="id5" name="czek[]" value="5" />
  8.  
  9. <input type="button" value="send" onClick="submitForm()" />
  10.  
  11. </form>


chciałbym jechać po kolei po id checkboksów i gdy dany checkbox nie jest zachaczony zachaczyć go i nadać wartość "x" i wysłać form
  1. function submitForm()
  2. {
  3. var number = 1;
  4. var elementy = document.forms['myForm'].elements;
  5. var ile = elementy.length - 1;
  6.  
  7. alert(ile);
  8.  
  9. for( var i = 1 ; i <= ile ; i++ )
  10. {
  11. if(document.getElementById("id" + i).checked == false)
  12. {
  13. document.getElementById("id" + i).checked = true;
  14. document.getElementById("id" + i).value = "x";
  15. }
  16. }
  17.  
  18. document.forms.myForm.submit();
  19. }


Ten post edytował john_doe 20.09.2010, 15:30:27
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: 16.09.2025 - 04:15