Advertisement
Guest User

Multilevel check boxes

a guest
Jul 22nd, 2014
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. /*
  2. Conditions:
  3. 1. Celetti checked - Copricassonetto and/or Persiane not clickable.
  4. 2. Motori and/or Avvolgibili checked - Persiane not clickable.
  5. 3. Persiane checked - Copricassonetto and/or Celetti not clickable
  6.  
  7. fields:
  8. <input type="checkbox" class="form-checkbox" id="input_34_0" name="q34_serviziAggiuntivi[]" value="Celetti" />
  9. <input type="checkbox" class="form-checkbox" id="input_34_1" name="q34_serviziAggiuntivi[]" value="Motori" />
  10. <input type="checkbox" class="form-checkbox" id="input_34_2" name="q34_serviziAggiuntivi[]" value="Avvolgibili" />
  11. <input type="checkbox" class="form-checkbox" id="input_34_3" name="q34_serviziAggiuntivi[]" value="Persiane" />
  12. <input type="checkbox" class="form-checkbox" id="input_34_4" name="q34_serviziAggiuntivi[]" value="Copricassonetto" />
  13. <input type="checkbox" class="form-checkbox" id="input_34_5" name="q34_serviziAggiuntivi[]" value="Zanzariere" />
  14. <input type="checkbox" class="form-checkbox" id="input_35_6" name="q34_serviziAggiuntivi[]" value="Grate" />
  15. */
  16.  
  17. document.ready(function($) {
  18.  
  19. // general helper functions
  20. function disable(check) {
  21. $(check).attr('checked', false);
  22. $(check).attr("disabled", true);
  23. }
  24.  
  25. function enable(check) {
  26. $(check).removeAttr("disabled");
  27. }
  28.  
  29. // 1. Celetti checked - Copricassonetto and/or Persiane not clickable.
  30. $('#input_34_0').change(function() {
  31. if( $(this).is(':checked') ) {
  32. disable('#input_34_3');
  33. disable('#input_34_4');
  34. } else {
  35. enable('#input_34_3');
  36. enable('#input_34_4');
  37. }
  38. });
  39.  
  40. // 2a. Motori checked - Persiane not clickable.
  41. $('#input_34_1').change(function() {
  42. if( $(this).is(':checked') ) {
  43. disable('#input_34_3');
  44. } else {
  45. enable('#input_34_3');
  46. }
  47. });
  48.  
  49. // 2b. Avvolgibili checked - Persiane not clickable.
  50. $('#input_34_2').change(function() {
  51. if( $(this).is(':checked') ) {
  52. disable('#input_34_3');
  53. } else {
  54. enable('#input_34_3');
  55. }
  56. });
  57.  
  58. // 3. Persiane checked - Copricassonetto and/or Celetti not clickable
  59. $('#input_34_3').change(function() {
  60. if( $(this).is(':checked') ) {
  61. disable('#input_34_0');
  62. disable('#input_34_4');
  63. } else {
  64. enable('#input_34_0');
  65. enable('#input_34_4');
  66. }
  67. });
  68. }.bind(window, jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement