Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- // by default, hide the address fields
- $(document).ready(function() {
- $('input[name=address1]').closest('div[id*=formElement]').hide();
- $('input[name=address2]').closest('div[id*=formElement]').hide();
- $('input[name=city]').closest('div[id*=formElement]').hide();
- $('input[name=zipPostal]').closest('div[id*=formElement]').hide();
- $('select[name=country]').closest('div[id*=formElement]').hide();
- });
- // show the address fields when one of the checkboxes is checked
- $(document).on('change', 'input[name*=tickbox]', function(){
- var tickboxChecked=$('input[name*=tickbox]:checked').length;
- // console.log(tickboxChecked);
- if(tickboxChecked>0){
- $('input[name=address1]').closest('div[id*=formElement]').show();
- $('input[name=address2]').closest('div[id*=formElement]').show();
- $('input[name=city]').closest('div[id*=formElement]').show();
- $('input[name=zipPostal]').closest('div[id*=formElement]').show();
- $('select[name=country]').closest('div[id*=formElement]').show();
- }
- // else hide the address fields if none of the checkboxes are checked
- else if (tickboxChecked==0) {
- $('input[name=address1]').closest('div[id*=formElement]').hide();
- $('input[name=address2]').closest('div[id*=formElement]').hide();
- $('input[name=city]').closest('div[id*=formElement]').hide();
- $('input[name=zipPostal]').closest('div[id*=formElement]').hide();
- $('select[name=country]').closest('div[id*=formElement]').hide();
- }
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement