# Accessing variables data from an HTML code block

**URL:** <https://community.weweb.io/t/accessing-variables-data-from-an-html-code-block/9272>\
**Category:** How do I?\
**Created:** [June 22, 2024, 8:17pm UTC](https://community.weweb.io/t/accessing-variables-data-from-an-html-code-block/9272 "2024-06-22T20:17:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![EnigmaXXIII](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@EnigmaXXIII](https://community.weweb.io/u/EnigmaXXIII)\
**Post date:** [June 22, 2024, 8:17pm UTC](https://community.weweb.io/t/accessing-variables-data-from-an-html-code-block/9272/1 "2024-06-22T20:17:16Z")

</div>

Hi All,

I’m struggling with this a bit and haven’t found an exact answer. Is it possible to access variable data from the HTML block? I have some vars set and I have some JS rendering dynamic content based on the variables, but I cannot seem to actually get the data into the HTML block.

Any ideas?

Thanks.

---

<div class="post-metadata">

**Author:** ![raydeck](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raydeck/32/384_2.png) [@raydeck](https://community.weweb.io/u/raydeck)\
**Post date:** [June 22, 2024, 9:43pm UTC](https://community.weweb.io/t/accessing-variables-data-from-an-html-code-block/9272/2 "2024-06-22T21:43:43Z")

</div>

Yes I made some videos about bridging between js land and weweb:

Bridging Weweb and Javascript Variables in under 15 minutes

[![](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/e/ed2ee177ec21f1704ebdfd8a2f07ca1d518df752.jpeg "Bridging Weweb and Javascript Variables in under 15 minutes") ](https://www.youtube.com/watch?v=77EPEtN49U4)

---

<div class="post-metadata">

**Author:** ![EnigmaXXIII](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@EnigmaXXIII](https://community.weweb.io/u/EnigmaXXIII)\
**Post date:** [June 22, 2024, 9:45pm UTC](https://community.weweb.io/t/accessing-variables-data-from-an-html-code-block/9272/3 "2024-06-22T21:45:16Z")

</div>

@raydeck thanks for this. Your video was one of the first things I looked at, however, it doesn’t seem like I’m able to directly access the wwLib vars in the normal HTML editor?

---

<div class="post-metadata">

**Author:** ![raydeck](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raydeck/32/384_2.png) [@raydeck](https://community.weweb.io/u/raydeck)\
**Post date:** [June 22, 2024, 9:46pm UTC](https://community.weweb.io/t/accessing-variables-data-from-an-html-code-block/9272/4 "2024-06-22T21:46:27Z")

</div>

If you are writing js in the block you can access using that technique - or should be able to. Can you share more about the problem?

---

<div class="post-metadata">

**Author:** ![EnigmaXXIII](https://avatars.discourse-cdn.com/v4/letter/e/4da419/32.png) [@EnigmaXXIII](https://community.weweb.io/u/EnigmaXXIII)\
**Post date:** [June 22, 2024, 10:22pm UTC](https://community.weweb.io/t/accessing-variables-data-from-an-html-code-block/9272/5 "2024-06-22T22:22:20Z")

</div>

It just seems like nothing happens at all when using the HTML element. For example, this code should print the content of the variable to console, but it does nothing:

```auto
<script>
// Retrieve the musicData using the correct WeWeb method and log it to console
try {
    const printData = wwLib.wwVariable.getValue("my var id");
    console.log('Print Data:', printData);
} catch (error) {
    console.error('Error accessing data:', error);
}
</script>

```

I’ve even tried accessing the variable and just displaying it on the page directly, but nothing. There’s a good chance I’m doing something wrong this with method. Though, if I bind the block to some JS that takes the vars as input and renders the HTML as a return string, then it works fine. It’s a little clunky to do it this way - but I’m wondering if I’m missing something obvious?
