Streaming live at 10am (PST)

How to create a page that shows a new randomized sentence at click of a button


#1

Hello!

I am trying to create a page for a friend where a single funny tweet or thought he has appears on the page. Below this line of text is a button that says "Another!". What I would like to happen is that you can click on this button and a new line of text appears--sort of like a magic 8-ball. I would also like the text on the button to change words too.


What I did was make two collections: one for the central text and one for the button text. I then made a dynamic list with a random sorting order and limiting it to 1 item from the collection. I added a script to the button so that when pressed it refreshes the page. The problem is that I can't seem to actually randomize it. it will only randomize if i publish the site again.

I looked on the forums, and there was an article about how you can randomize the sort order, and (using a custom script) trigger the randomizing upon a refresh. The problem with this, though, is that it only works if you display all the items in your collection. I only want to display a single item from my collection, but which one that is changes on each refresh.
Can you all think of something I could do to achieve this?
(when you click on my public share link, the page i am trying to work on is called thoughts.)

Thank you!

Here is my public share link: LINK
(how to access public share link)


#2

Correct. List out everything, but in a hidden state. Use a script to only show a random one.


#3

Thank you for the reply!

If I list everything, but have them hidden, would i need to make the Next Button part of each CMS entry so that people aren't scrolling through a bunch of blank space to reach the next button at the bottom of the screen? Is the script something that should be easy to figure out on my own? (I am not a coder, just like doing things myself like trying to make a website, so this question might be very naive.)


#4

Oh, I see the code, there are already no spaces to begin with, which makes it impossible.

Maybe perhaps we can try substituting a space for another character in the editor, like a * for one space... but I wouldn't like that.


#5

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.