top of page

Forum Posts

carrie
Jan 29, 2021
In Coding with Velo
Hi there, I am working on my very first Wix site and I've run into the following problem: I have a Collection called "videos" with the following columns: title, videoUrl, date. On my webpage, I have dragged the "Embed Website" component onto the page, and in my code I'm trying to populate the src of the iframe with the videoURL from the Collection with a date that matches today's date. I'm using this solution as a reference: https://www.wix.com/velo/forum/community-discussion/display-different-a-image-from-a-db-based-on-date-range But it's not working for me and I cannot figure out my mistake. My site is unpublished and I am querying the collection directly, not using a dataset. I've been testing by clicking the preview button, but nothing in the iframe renders. Any help would be greatly appreciated! Here is my full code: <iframe id="iframe" src="" width="560" height="315" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen> </iframe> <script> import wixWindow from 'wix-window'; import wixData from 'wix-data'; $w.onReady(function () { let todayDate = new Date(); wixData.query('videos') .eq('date', todayDate) .find().then(results => { console.log(results) $w('#iframe').src = results.items[0].videoUrl; }); }); </script>
0
1
83

carrie

More actions
bottom of page