How to use button to trigger javascript in cms collection list

I have a random script within my cms collection list - it’s working fine thanks to Ben parker

Now this works on the collection list but I want it to work from my home page. How can I trigger a button then run that script?

Homepage read only link
CMS Collection Read only link

Additionally does anyone know how I can show a new cms items per day? Like todays daily feature is…

Hi @chadmueller, the script is triggered by the inline javascript on the embed button:

<a href="#" class="button w-button" onClick="setTimeout(openSite, 2000)">New Prompt</a> notice the ‘onClick…’

Copying this embed button to the homepage along with the script should make it work on the homepage too.

To answer your 2nd question: You can do this by scheduling, i.e. manually upload new items and let the scheduling publish it on the right day.

Ahhhhh - so simple - thank you very much!

yeah I was hoping that I could have a script that would pull a new item from the cms and make it the default on loading. Doesn’t seem far off “random image on page refresh” - thought I could bound that by date.

I believe pulling from the CMS is possible but will take API knowledge. Otherwise yes, you can bind by a starting date. Something like current date - starting date = number. And then check that number against the length of the CMS.

1 Like