Displaying images from pool by referring to a variable in inline_html/javascript
in OSWeb
Hello!
My question is similar to the post below, only I am trying to achieve sort of the same thing with html and javascript.
I have created a custom form with inline_html and I want to loop through a list of image names stored in a variable named "image."
<img src = {image}>
This wont work of course because I have to access the pool but I'm not sure if I can do that using a variable.
<img id = 'stim'/>
<script>
document.getElementById('stim').src = pool[(image)].data.src
</script>
Clearly, I'm lost when it comes to the syntax! Is there a way to achieve what I'm thinking?
Thanks!
Comments
Hi @vaishtables ,
The issue is simply that you're putting parentheses around
image. The following should work:<img id = 'stim'/> <script> document.getElementById('stim').src = pool[image].data.src </script>Hope this helps!
— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Oh my lord, it was that easy lmao! Thank you very much :)