1// a simple jQuery plugin 2// @see: http://learn.jquery.com/plugins/basic-plugin-creation/ 3//(function($) { 4 jQuery.fn.countChildren = function() { 5 return this.each(function() { 6 // check if we have the countChildren field 7 if (!jQuery(this).find("[name=countChildren]") 8 .change(function() { 9 jQuery(this).setChildNumDropdowns(); 10 }) 11 .size()) { 12 return; 13 } 14 // call it immediately 15 jQuery(this).setChildNumDropdowns(); 16 }); 17 }; 18 19 // shows as many dropdowns as many children are set 20 jQuery.fn.setChildNumDropdowns = function() { 21 // hide all sibling elements' containing divs 22 jQuery(this).closest("form").find(".ageChildren").closest(".form-group").hide(); 23 // display as many as the value is 24 for (var index=1; index <= jQuery(this).val(); index++) { 25 jQuery(this).closest("form").find("[name=ageChild_"+ index +"]").closest(".form-group").show(); 26 } 27 }; 28//})(jQuery); 29 30// checks the form for "number of children" elements and age fields 31jQuery(function() { 32 jQuery("form").countChildren(); 33}); 34 35 36 37
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.