# CMS Filter + Select Attribute Modification

**URL:** <https://forum.finsweet.com/t/cms-filter-select-attribute-modification/1752>\
**Category:** General\
**Created:** [August 8, 2023, 12:19am UTC](https://forum.finsweet.com/t/cms-filter-select-attribute-modification/1752 "2023-08-08T00:19:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathancovey](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/nathancovey/32/1193_2.png) [@nathancovey](https://forum.finsweet.com/u/nathancovey)\
**Post date:** [August 8, 2023, 12:19am UTC](https://forum.finsweet.com/t/cms-filter-select-attribute-modification/1752/1 "2023-08-08T00:19:20Z")

</div>

I’m using the Finsweet CMS Filter + Select Attribute for one of my projects, but I need it to do something a little different and was seeing if anyone could help.

The project is for an organization that has several different locations but a similar equestrian therapy program. Each location has some differences for their program including cost, address, and some add-ons.

Here is the page for the therapy program: [Girls Experience](https://bridleuphope.webflow.io/girls-experience)

At the top, I want someone to be able to select a location from the dropdown, and then certain information on the rest of the page will dynamically adjust for that selected location (pulling from my “Locations” CMS collection).

There are two problems I’m running into:

1. The default state before a location is selected shows all the information for every location. I don’t want anything to show up until a location is selected:  
 ![Screenshot 2023-08-07 at 8.09.23 PM](https://europe1.discourse-cdn.com/flex013/uploads/finsweet1/original/2X/d/d5894810f8bf2723f7061b488c5229775c8d9b39.png)
2. I must’ve set something up incorrectly with the CMS Filter + Select attribute because I can’t even get any information to show up once a location is selected:  
 ![Screenshot 2023-08-07 at 8.17.10 PM](https://europe1.discourse-cdn.com/flex013/uploads/finsweet1/original/2X/7/73dc24c0a670fc3a3c557f5c22fff3db476587b9.jpeg)  
 ![Screenshot 2023-08-07 at 8.17.14 PM](https://europe1.discourse-cdn.com/flex013/uploads/finsweet1/original/2X/7/72aa11fafb793edfee266ed166564633f4e56dfc.png)

Hopefully this makes sense. Would appreciate anyone’s help on this 🙏

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [August 8, 2023, 12:33am UTC](https://forum.finsweet.com/t/cms-filter-select-attribute-modification/1752/2 "2023-08-08T00:33:12Z")

</div>

Hey @nathancovey! The first issue can be addressed by this option available for CMS Filter.

 ![Screen Shot 2023-08-07 at 18.24.30](https://europe1.discourse-cdn.com/flex013/uploads/finsweet1/original/2X/c/c6e15bd1f4ba6c4ecd8b755d1ccc83e28be916d7.png)

The list is disappearing whenever you select a location because there is no `fs-cmsfilter-field` attribute in your items. Please add this and test once again 🙂

---

<div class="post-metadata">

**Author:** ![nathancovey](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/nathancovey/32/1193_2.png) [@nathancovey](https://forum.finsweet.com/u/nathancovey)\
**Post date:** [August 8, 2023, 2:08am UTC](https://forum.finsweet.com/t/cms-filter-select-attribute-modification/1752/3 "2023-08-08T02:08:50Z")

</div>

It worked! Thank you so much!

---

<div class="post-metadata">

**Author:** ![nathancovey](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/nathancovey/32/1193_2.png) [@nathancovey](https://forum.finsweet.com/u/nathancovey)\
**Post date:** [August 8, 2023, 1:44pm UTC](https://forum.finsweet.com/t/cms-filter-select-attribute-modification/1752/4 "2023-08-08T13:44:29Z")

</div>

@Support-Luis Can I set two different div blocks to have an initial state? Or can I only apply it to one at a time

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [August 8, 2023, 3:49pm UTC](https://forum.finsweet.com/t/cms-filter-select-attribute-modification/1752/5 "2023-08-08T15:49:33Z")

</div>

Hey @nathancovey! It should be one empty state per instance. But let me know your use case and we might be able to add some custom code to your site 🙂

---

<div class="post-metadata">

**Author:** ![nathancovey](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/nathancovey/32/1193_2.png) [@nathancovey](https://forum.finsweet.com/u/nathancovey)\
**Post date:** [August 8, 2023, 6:56pm UTC](https://forum.finsweet.com/t/cms-filter-select-attribute-modification/1752/6 "2023-08-08T18:56:02Z")

</div>

@Support-Luis Sweet!

So I would love to be able to have 3 different div blocks as initial states on this page: [Girls Experience](https://bridleuphope.webflow.io/girls-experience)

1. This  

2. This  

3. This  

Let me know if this would be possible. Thanks!

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [August 8, 2023, 11:12pm UTC](https://forum.finsweet.com/t/cms-filter-select-attribute-modification/1752/7 "2023-08-08T23:12:17Z")

</div>

hey @nathancovey!

Can you please add this code to your `</body>`?

```auto
<script>
  window.fsAttributes = window.fsAttributes || [];
  window.fsAttributes.push([
    'cmsfilter',
    (filterInstances) => {
      console.log('cmsfilter Successfully loaded!');

      const [filterInstance] = filterInstances;

      const intialSateElements = document.querySelectorAll("[fs-cmsfilter-element='initial']");

      const mutationCallback = (targetElement, mutationsList, observer) => {
        for (const mutation of mutationsList) {
          if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
            const computedStyle = window.getComputedStyle(targetElement);
            const display = computedStyle.getPropertyValue('display');

            if (display === 'none') {
              hideOtherElements(targetElement);
            } else {
              showOtherElements(targetElement);
            }
          }
        }
      };

      function hideOtherElements(triggeringElement) {
        // Loop through the initial state elements and hide them except the triggering element
        for (const element of intialSateElements) {
          if (element !== triggeringElement) {
            element.style.display = 'none';
          }
        }
      }

      function showOtherElements(triggeringElement) {
        // Loop through the initial state elements and show them except the triggering element
        for (const element of intialSateElements) {
          if (element !== triggeringElement) {
            element.style.display = ''; // This restores the default display property
          }
        }
      }

      intialSateElements.forEach((element) => {
        const observer = new MutationObserver((mutationsList) =>
          mutationCallback(element, mutationsList, observer)
        );

        // Start observing the current element for attribute changes
        observer.observe(element, { attributes: true });
      });
    },
  ]);
</script>

```

---

<div class="post-metadata">

**Author:** ![nathancovey](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/nathancovey/32/1193_2.png) [@nathancovey](https://forum.finsweet.com/u/nathancovey)\
**Post date:** [August 11, 2023, 1:59pm UTC](https://forum.finsweet.com/t/cms-filter-select-attribute-modification/1752/8 "2023-08-11T13:59:32Z")

</div>

@Support-Luis It worked like a charm! Thank you! You guys are the best!

---

<div class="post-metadata">

**Author:** ![Support-Luis](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.finsweet.com/support-luis/32/53_2.png) [@Support-Luis](https://forum.finsweet.com/u/Support-Luis)\
**Post date:** [August 11, 2023, 6:11pm UTC](https://forum.finsweet.com/t/cms-filter-select-attribute-modification/1752/9 "2023-08-11T18:11:01Z")

</div>

You are welcome! 💪
