# How to get a JS variable value through a bubble embed?

**URL:** <https://forum.bubble.io/t/how-to-get-a-js-variable-value-through-a-bubble-embed/267498>\
**Category:** Plugins\
**Created:** [June 13, 2023, 8:05pm UTC](https://forum.bubble.io/t/how-to-get-a-js-variable-value-through-a-bubble-embed/267498 "2023-06-13T20:05:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathan\_bn](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jonathan\_bn](https://forum.bubble.io/u/jonathan_bn)\
**Post date:** [June 13, 2023, 8:05pm UTC](https://forum.bubble.io/t/how-to-get-a-js-variable-value-through-a-bubble-embed/267498/1 "2023-06-13T20:05:07Z")

</div>

This store doesn’t have a rating system by default, so a started to build one via bubble, the store only accepts javascripts and HTML codes to be inserted.

So on the store panel i maked this code to show the embeded page that will show the comments/ratings and also gets the product id that’s inside a hidden input.

```
//gets the product id that's inside a hidden input

const produto_id = document.querySelector('input[name="produto_id"]').value;
console.log(produto_id);

//inserts the iframe inside the div .secao-secundaria
const corpo = document.querySelector(".secao-secundaria");
const embed = document.createElement("iframe");

// Define the properties of the iframe
embed.setAttribute('src', 'https://lamavi.bubbleapps.io/version-test/comentarios');
embed.setAttribute('width', '100%');
embed.setAttribute('height', 'auto');
embed.style.border = "none"; // Remove borders
embed.style.overflow = "hidden"; // Remove scroll

corpo.after(embed);

```

With that i was able to display the embed bubble correctly, and show the id in the console.log.

![Captura de tela 2023-06-13 162724](https://us1.discourse-cdn.com/bubble/original/3X/4/f/4f5fbc2d46aae8fcff83ac99b7bc3204be2cfec0.png)

However i’m having issues trying to get this id on bubble via JS, i tried using this line of code on toobox that should get the value, but it doesn’t.

```
const produto_id = document.querySelector('input[name="produto_id"]').value;
console.log(produto_id);

bubble_fn_getid(produto_id)

```

![Captura de tela 2023-06-13 164621](https://us1.discourse-cdn.com/bubble/original/3X/5/c/5c756343a227707c9bd1f5f16a4ac734d76b1226.png)

 ![Captura de tela 2023-06-13 164603](https://us1.discourse-cdn.com/bubble/original/3X/a/a/aa56570c21ce4fafe4c0a36601b1376dd1c23c9e.png)

Any ideas that can solve this? what i’m doing wrong 🤷‍♂️, thanks in advance.

---

<div class="post-metadata">

**Author:** ![jonah.deleseleuc](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jonah.deleseleuc/32/199133_2.png) [@jonah.deleseleuc](https://forum.bubble.io/u/jonah.deleseleuc)\
**Post date:** [June 13, 2023, 9:08pm UTC](https://forum.bubble.io/t/how-to-get-a-js-variable-value-through-a-bubble-embed/267498/2 "2023-06-13T21:08:35Z")

</div>

Are you trying to manipulate the DOM of the website inside the iFrame? Or are you trying to simply access information from the iFrame. Also, I would suggest moving this post to the plugins builder sub forum because the people there are more familiar with code.

---

<div class="post-metadata">

**Author:** ![jonathan\_bn](https://avatars.discourse-cdn.com/v4/letter/j/90ced4/32.png) [@jonathan\_bn](https://forum.bubble.io/u/jonathan_bn)\
**Post date:** [June 13, 2023, 10:02pm UTC](https://forum.bubble.io/t/how-to-get-a-js-variable-value-through-a-bubble-embed/267498/3 "2023-06-13T22:02:33Z")

</div>

No, i’m just trying to get the product id to make a search on bubble db and show only the commets related to that product. Maybe i dind’t make myselft clear, but there’s a store and on the footer i embed bubble page that will have a RG where i make a search and that search needs to filter the comments related to the product page, all i wanna to do is get the product id of the page on the embed to make that.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [August 22, 2023, 8:06pm UTC](https://forum.bubble.io/t/how-to-get-a-js-variable-value-through-a-bubble-embed/267498/4 "2023-08-22T20:06:05Z")

</div>

This topic was automatically closed after 70 days. New replies are no longer allowed.
