# Subscription Preferences Toggle - move all on "unsubscribe"

**URL:** <https://community.hubspot.com/t/subscription-preferences-toggle-move-all-on-unsubscribe/67289>\
**Category:** CMS Development\
**Created:** [October 17, 2022, 3:29pm UTC](https://community.hubspot.com/t/subscription-preferences-toggle-move-all-on-unsubscribe/67289 "2022-10-17T15:29:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snacks](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@snacks](https://community.hubspot.com/u/snacks)\
**Post date:** [October 17, 2022, 3:29pm UTC](https://community.hubspot.com/t/subscription-preferences-toggle-move-all-on-unsubscribe/67289/1 "2022-10-17T15:29:37Z")

</div>

Currently have checkboxes styled to toggles on the email preferences page.

The movement, colors, and disabled features all work.

I am struggling to have the preferences toggles move when “unsubscribe all” is selected.

Currently, the preference options grey out and become disabled, but having the toggles also move is crucial.

Potental Jquery solution that I found:

```lia-code-sample
<script>
$('#globalunsub').click(function (){
 const isChecked = $(this).prop('checked');

 $('input').each(function (){
 $(this).prop('checked', isChecked);
 });
 });

 $('input:not(#globalunsub)').click(function (){
 $('#globalunsub').prop('checked', false);
 });
});
</script>

```

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [October 17, 2022, 10:45pm UTC](https://community.hubspot.com/t/subscription-preferences-toggle-move-all-on-unsubscribe/67289/2 "2022-10-17T22:45:31Z")

</div>

Hi, @snacks 👋 Thanks for reaching out! And thank you for including those details. Hey, @BarryGrennan @Indra have you managed a customization like what @snacks is describing? Thank you very much for taking a look! — Jaycee

---

<div class="post-metadata">

**Author:** ![Indra](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/indra/32/98381_2.png) [@Indra](https://community.hubspot.com/u/Indra)\
**Post date:** [October 18, 2022, 5:58am UTC](https://community.hubspot.com/t/subscription-preferences-toggle-move-all-on-unsubscribe/67289/3 "2022-10-18T05:58:11Z")

</div>

Thanks for mentioning [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074)!

Hi @snacks,

You can use the [HubSpot CMS boilerplate](https://github.com/HubSpot/cms-theme-boilerplate) as an default for this to use. Check out the [main.js](https://github.com/HubSpot/cms-theme-boilerplate/blob/main/src/js/main.js).

The part you are looking for is added below:

```lia-code-sample
(function () {
 // Variables
 var emailGlobalUnsub = document.querySelector('input[name="globalunsub"]');

 // Functions

 // Function to disable the other checkbox inputs on the email subscription system page template
 function toggleDisabled() {
 var emailSubItem = document.querySelectorAll('#email-prefs-form .item');

 emailSubItem.forEach(function (item) {
 var emailSubItemInput = item.querySelector('input');

 if (emailGlobalUnsub.checked) {
 item.classList.add('disabled');
 emailSubItemInput.setAttribute('disabled', 'disabled');
 emailSubItemInput.checked = false;
 } else {
 item.classList.remove('disabled');
 emailSubItemInput.removeAttribute('disabled');
 }
 });
 }

 // Execute JavaScript on document ready
 domReady(function () {
 if (!document.body) {
 return;
 } else {
 // Function dependent on email unsubscribe from all input
 if (emailGlobalUnsub) {
 emailGlobalUnsub.addEventListener('change', toggleDisabled);
 }
 }
 });
})();

```

---

<div class="post-metadata">

**Author:** ![snacks](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@snacks](https://community.hubspot.com/u/snacks)\
**Post date:** [October 24, 2022, 2:04pm UTC](https://community.hubspot.com/t/subscription-preferences-toggle-move-all-on-unsubscribe/67289/4 "2022-10-24T14:04:55Z")

</div>

Hey Indra, thank you for the update and the potential solution.

I plugged it in but am not having any luck.

Will come back to this later, thank you for your help though.
