Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript] blokowanie/odblokowowywanie checboxow
lnn
post
Post #1





Grupa: Zarejestrowani
Postów: 361
Pomógł: 11
Dołączył: 17.12.2008
Skąd: LU

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


witam

chcialem zrobic cos takiego zeby po zaznaczeniu pola typu checbox oblokowywaly sie inne pola, lecz dziala to tylko jesli jest umieszczone w jednym div-ie, a chcialem poumieszczac to w oddzielnych divach i wtedy przestaje mi dzialac :/ swita mi pomysl zeby to jakos po identyfikatorze wywolywac ale nie wiem jak to uczynic.. pomoglby ktos?

  1. <input type="checkbox" name="wyzywienie_on" onclick="
  2. this.form.elements['sniadanie'].disabled =
  3. this.form.elements['obiad'].disabled =
  4. this.form.elements['kolacja'].disabled =
  5. this.form.elements['obiadokolacja'].disabled =
  6. this.form.elements['calodzienne'].disabled =
  7. this.form.elements['ch_s'].disabled =
  8. this.form.elements['ch_o'].disabled =
  9. this.form.elements['ch_ok'].disabled =
  10. this.form.elements['ch_k'].disabled =
  11. this.form.elements['ch_c'].disabled =
  12. !this.checked" />dostępne <br />
  13. śniadanie: <input type="text" name="sniadanie" size="10" disabled="disabled" />
  14. <input type="checkbox" name="ch_s" value="on" disabled="disabled" />wliczone<br>
  15. Obiad: <input type="text" name="obiad" size="8" disabled="disabled" />
  16. <input type="checkbox" name="ch_o" value="ON" disabled="disabled" />wliczone<br>
  17. Obiadokolacja: <input type="text" name="obiadokolacja" size="8" disabled="disabled" />
  18. <input type="checkbox" name="ch_ok" value="ON" disabled="disabled" />wliczone<br>
  19. Kolacja: <input type="text" name="kolacja" size="12" disabled="disabled" />
  20. <input type="checkbox" name="ch_k" value="ON" disabled="disabled" />wliczone<br>
  21. Całodzienne: <input type="text" name="calodzienne" size="12" disabled="disabled" />
  22. <input type="checkbox" name="ch_c" value="ON" disabled="disabled" />wliczone
Go to the top of the page
+Quote Post
Burned
post
Post #2





Grupa: Zarejestrowani
Postów: 67
Pomógł: 8
Dołączył: 19.05.2004
Skąd: Warszawa

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


getElementById
Go to the top of the page
+Quote Post
kefirek
post
Post #3





Grupa: Zarejestrowani
Postów: 781
Pomógł: 256
Dołączył: 29.06.2008

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


[JAVASCRIPT] pobierz, plaintext
  1. <html>
  2. <head>
  3. <script src="http://code.jquery.com/jquery-latest.js"></script>
  4. <script>
  5. $(document).ready(function(){
  6. $('input[name=wyzywienie_on]').click(function() {
  7. if (this.checked == true) $(".check").attr('disabled', false); else $(".check").attr('disabled', true);
  8. });
  9.  
  10. });
  11.  
  12.  
  13.  
  14.  
  15.  
  16. </script>
  17. </head>
  18. <body>
  19. <input type="checkbox" name="wyzywienie_on" />dostępne <br />
  20.  
  21. &para;niadanie: <input class="check" type="text" name="sniadanie" size="10" disabled="disabled" />
  22. <input class="check" type="checkbox" name="ch_s" value="on" disabled="disabled" />wliczone<br>
  23. Obiad: <input class="check" type="text" name="obiad" size="8" disabled="disabled" />
  24. <input class="check" type="checkbox" name="ch_o" value="ON" disabled="disabled" />wliczone<br>
  25. Obiadokolacja: <input class="check" type="text" name="obiadokolacja" size="8" disabled="disabled" />
  26. <input class="check" type="checkbox" name="ch_ok" value="ON" disabled="disabled" />wliczone<br>
  27. Kolacja: <input class="check" type="text" name="kolacja" size="12" disabled="disabled" />
  28. <input class="check" type="checkbox" name="ch_k" value="ON" disabled="disabled" />wliczone<br>
  29. Całodzienne: <input class="check" type="text" name="calodzienne" size="12" disabled="disabled" />
  30. <input class="check" type="checkbox" name="ch_c" value="ON" disabled="disabled" />wliczone
  31. </body>
  32. </html>
[JAVASCRIPT] pobierz, plaintext
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 00:42