# Dynamic count variable for inner Blocks possible?

**URL:** https://forum.pinegrow.com/t/dynamic-count-variable-for-inner-blocks-possible/8027
**Category:** Pinegrow WP
**Created:** [May 13, 2023, 2:28pm UTC](https://forum.pinegrow.com/t/dynamic-count-variable-for-inner-blocks-possible/8027 "2023-05-13T14:28:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![MichelyWeb](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/michelyweb/32/6652_2.png) [@MichelyWeb](https://forum.pinegrow.com/u/MichelyWeb)
#### Post date: [May 13, 2023, 2:28pm UTC](https://forum.pinegrow.com/t/dynamic-count-variable-for-inner-blocks-possible/8027/1 "2023-05-13T14:28:41Z")

</div>

I’ve created a JS Blocks FAQ Accordion that should be accessible. Problem is, that i can not find a way to count up the needed ids and aria Attributes (e.g. `aria-labelled-by`).

 ![CleanShot 2023-05-13 at 16.23.04@2x](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/1/168c4ccaf44841567e6d0b5753f71c4613f36d54.jpeg)

Is there a chance to get this working without making it a PHP/ACF Block?

---

<div class="post-metadata">

### Author: ![adamslowe](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/adamslowe/32/4590_2.png) [@adamslowe](https://forum.pinegrow.com/u/adamslowe)
#### Post date: [May 13, 2023, 8:59pm UTC](https://forum.pinegrow.com/t/dynamic-count-variable-for-inner-blocks-possible/8027/2 "2023-05-13T20:59:16Z")

</div>

I haven’t found a way to do it with pure Pinegrow, unfortunately. Here, JavaScript is going to be your friend.

Another option is to use nested blocks and set the IDs and attributes manually on the children blocks as block properties. That’s how I’ve done it with mine. It’s ugly since I have to set the ID and attributes for each item, but it works.

If I’m not mistaken, Alpine Components had a great example on how to use their library to do just that. I use their button in my menu for drop downs and it does a great job of making dynamic IDs for accessibility.

---

<div class="post-metadata">

### Author: ![matjaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/matjaz/32/5_2.png) [@matjaz](https://forum.pinegrow.com/u/matjaz)
#### Post date: [May 14, 2023, 1:46am UTC](https://forum.pinegrow.com/t/dynamic-count-variable-for-inner-blocks-possible/8027/3 "2023-05-14T01:46:39Z")

</div>

This could be done by having some kind of a global variable that is incremented each time and used to set the ids.

WP takes care of displaying inner blocks and we don’t have much control over that.
